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

ensure utf-8 decode by default #2

Open
PopovK opened this issue May 26, 2015 · 0 comments
Open

ensure utf-8 decode by default #2

PopovK opened this issue May 26, 2015 · 0 comments

Comments

@PopovK
Copy link

PopovK commented May 26, 2015

Hi,
it's a helpful tool you've done, but when trying to make it works under linux ubuntu, I ran into this critical error as soon as it reached a step requiring to decode the JSON data :

/dff/battle/get_battle_init_data called
Traceback (most recent call last):
File "FFRKProxy.py", line 113, in
...
File "FFRKProxy.py", line 70, in handle_response
json_data = json.loads(flow.response.content)
File "/usr/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Problem is, it seems that by default on linux, it doesn't check or default to utf, the data type needs to be explicit.
I used the solution given here for Windows :
https://www.reddit.com/r/FFRecordKeeper/comments/34p36e/how_to_peek_items_drops_in_windows/cqwyroo

by adding a .decode('utf-8-sig') to all json.loads(flow.response.content), and it worked perfectly

Could you add this as default, or in a less static way, reuse in the json.loads the charset data from the http response-headers ?
It would fix both the issue on Windows and on some, if not all, linux distribs

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

1 participant