Skip to content

Conversation

ankittripathi1
Copy link

fixes: #58718

add support for utf-16 encoding in blog decoder.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 20, 2025
Comment on lines +293 to +294
if(charset.toLowerCase() === 'utf-16'){
const decoder = new TextDecoder(charset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be any valid charset option? Maybe better to generalize this and add support for a custom charset for the decoding

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankittripathi1
Copy link
Author

Sorry i overlooked that the text() method supposed to always decode as UTF-8 according to specs.
Would it make more sense to add a separate method like textwithencoding(charset)?

@jasnell
Copy link
Member

jasnell commented Jun 20, 2025

We generally do not add non-standard methods to standard APIs so adding a new textwithencoding method wouldn't work. Adding encoding support directly to blob likely is a non-starter. You can, fairly trivially combine use of Blob with TextEncoder/TextDecoder to get the necessary encoding support.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a change that should be proposed upstream in the spec first.

@ankittripathi1
Copy link
Author

Then should I close this PR?

@jasnell
Copy link
Member

jasnell commented Jun 20, 2025

Yeah, closing I think is best.

@jimmywarting
Copy link

Hmm, annoying that different env behave differently...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reading UTF16 with BOM from Blob
6 participants