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
Wand should not rely on default encoding on Python 2.x #163
Comments
ImageMagick actually seems to provide a property to set string encoding ( |
Just my thoughts, you may of course do something else :-): then Wand maybe should not directly expose |
I made a small change ☝️ for this. |
Great, thanks. |
Example code:
With Wand 0.3.5, Python 2.7 on Linux (Ubuntu 12.04) this results in
The reason is that in
compat.py
(https://github.com/dahlia/wand/blob/master/wand/compat.py#L44) we are currently doing a simplereturn string.encode()
. If called without arguments,encode
uses the current default string encoding which is ASCII in case of Python 2. Obviously, ASCII cannot encode my greek character there and the UnicodeEncodeError is thrown.We cannot and dont want to change the fact that ASCII is Python 2's default encoding. Relevant discussion about this topic can be found here:
So the solution would be to make a well-grounded decision about which encoding to use. I tried UTF-8 and it worked for me (I changed line 44 of compat.py accordingly). I am not entirely sure why this works, for this I do not understand enough of which data format the imagemagick binaries do expect.
The text was updated successfully, but these errors were encountered: