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

Fix concatenation of chunks #46

Closed
wants to merge 2 commits into from

Conversation

tobias-khs
Copy link

Instead of using array.join, use Buffer.concat.

I came across of some corrupted characters when retrieving JSON data that contained Japanese text elements (utf8).

When making a request to a text resource the retrieved chunks from the http lib may split unicode characters. When joining (array.join) them some of these chunks start or end in corrupted characters. Using Buffer.concat(..) and then making the string conversion, potentially split characters are first put together correctly.

Instead of using array.join(''), use Buffer.concat(array).
@tobias-khs
Copy link
Author

I created a sample that should demonstrate this issue. The sample includes a small server which requires python.

@aacerox
Copy link
Owner

aacerox commented Sep 22, 2014

Done it!! I couldn't merge it automatically from github (don't know why), but this is yours.
Thank you

@aacerox aacerox closed this Sep 22, 2014
@tobias-khs
Copy link
Author

Thanks.

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

Successfully merging this pull request may close these issues.

2 participants