You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This uses TextDecoder for toString('utf8') and toString().
I needed to update some tests so that they are in line with Node's native Buffer (which also makes them pass with TextDecoder), I hope this was correct?
Technically, it also supports latin1, utf-16le, but the conversion is different from Node for strings that aren't representable in these encodings:
Great initiative @mischnic. I am using Buffer as a drop-in replacement for Node's versions. Changing the tests wouldn't work for me as then Buffer couldn't be used for that. Would it be possible to adjust the output of decoderUTF8.decode(buf.slice(start, end)) to adjust for this case? Maybe remove the "�" with utf16le and replace 0x13 with 0x96 with lading encoding?
I only used TextDecoder for utf8 because it seems to align with Buffer.toString("utf8"). The handling of the other encodings (utf16, latin) is still the same.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #268
This uses TextDecoder for
toString('utf8')andtoString().I needed to update some tests so that they are in line with Node's native
Buffer(which also makes them pass withTextDecoder), I hope this was correct?Technically, it also supports latin1, utf-16le, but the conversion is different from Node for strings that aren't representable in these encodings:
latin1:
utf16: (TextDecoder adds an "�" at the end. https://www.compart.com/en/unicode/U+FFFD)