-
Notifications
You must be signed in to change notification settings - Fork 317
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
Decoding issue with utf-8 #71
Comments
Are you running into any specific issues? |
|
Yes, I ran into exactly issue that I have described above. This is the first time I played with Dropbox API so I ran this snippet: Then I just got: In my Dropbox, I have a directory named "Tổ dân phố" and I think this string caused the issue. Are you sure that File names in Dropbox are all in UTF-8? What if the user used different encoding standard? The name is still unicode but under different encoding? |
|
It looks like the response you're getting is not valid UTF-8. That should never happen. Can you add the following line to "dropbox/dropbox.py", right before line 393: About Unicode/UTF-8 All Dropbox file name characters are definitely a subset of the Unicode character set. It doesn't actually matter what encoding Dropbox uses to store the file names; when the Dropbox API returns a JSON response, it will always encode things using UTF-8. Since UTF-8 can losslessly represent any Unicode string, this should work. |
|
This is what i got from that print: |
|
This is very strange. @braincore: Is there a way to turn on request/response logging? |
|
@cakoose This might do the trick, depending on what exactly you want logged: That will have it print the request and response, except for the the response body. |
|
That's exactly what I was looking for, thanks Greg. @tranvictor: Could you add the |
|
This is what I got: |
|
The server is sending back gzip-encoded content with the Can you try running this script: |
Yeah, I know that |
|
Looks like it's a bug in Requests 2.6.1. The release notes for 2.6.2 say:
I was able to reproduce the issue myself. Upgrading to a newer version of Requests fixed it. |
|
Ah thank you, it's fixed after I upgrade to newer version of requests too. |
As I can see in
dropbox/dropbox.py, line 393 and so on, you always decode the resp usingutf-8which I don't think it works properly in case the user has a non-utf8 file name.Should we use chardet to decode the resp to reduce error?
The text was updated successfully, but these errors were encountered: