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

Enforces UTF-8 decoding in WebResponse #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wildmichael
Copy link

WinHttpRequest uses the users current code page (CP_ACP) to decode the response body,
which on Windows is bound to fail for virtually all web services. This commit assumes the
response is in UTF-8, but to be correct it should be attempted to determine the encoding
from the Content-Type header followed by a fall-back to UTF-8. Also, the caller should have
a way of overriding the encoding. Also, maybe something along the lines of chardet could
be attempted.

WinHttpRequest uses the users current code page (CP_ACP) to decode the response body,
which on Windows is bound to fail for virtually all web services. This commit assumes the
response is in UTF-8, but to be correct it should be attempted to determine the encoding
from the Content-Type header followed by a fall-back to UTF-8. Also, the caller should have
a way of overriding the encoding. Also, maybe something along the lines of chardet could
be attempted.
@timhall
Copy link
Member

timhall commented Sep 20, 2017

Very cool! I’ve been looking for help on the UTF-8 issues and this is perfect. I’ll dive in and review this shortly

@wildmichael
Copy link
Author

Ha, just realized that in #276 it is mentioned that UTF-8 support is a problem on Mac, which my "hack" certainly will run into due to the use of MultiByteToWideChar(). Feel free to close the PR, I for myself had to fix the issue, but then Mac is a non-issue in my work environment.

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