Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting TypedArrays to text #46

Closed
devconcept opened this issue Feb 21, 2019 · 4 comments
Closed

Converting TypedArrays to text #46

devconcept opened this issue Feb 21, 2019 · 4 comments

Comments

@devconcept
Copy link

This library converts text/plain data to Uint8Array by default.

Why not preserve the _bodyBuffer content on the _emitBody call instead of discarding it so we don't have to convert it back to text for representation?

If there is a reason for this behavior you should consider an option to specify how to get the results of the parser.

@devconcept
Copy link
Author

devconcept commented Mar 11, 2019

Also when using the str2arr some characters are corrupted when decoding. Why not use the TextEncoder class to convert text to binary? Using your own functions causes TextDecoder not to work as expected.

@felixhammerl
Copy link
Contributor

The character corruption issue has been fixed in 2.0.6.

@felixhammerl
Copy link
Contributor

The API of the library was written so that it returns typed arrays no matter what the node was. Also, any text is converted to UTF-8, regardless of the input. Therefore, i don't quite see the benefit for this approach, as it's just one call to the TextEncoder...

@devconcept
Copy link
Author

Well one of the problem this library has is that, for example, it converts base64 string into a typed array, then it converts them into a regular string and then again into a typed array. This unnecessary conversion is the reason why sometimes you get corrupt data when using this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants