You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
With Wand 0.3.5, Python 2.7 on Linux (Ubuntu 12.04) this results in
File "/projects/bioinfp_apps/Python-2.7.3/lib/python2.7/site-packages/wand/drawing.py", line 431, in text
body = binary(body)
File "/projects/bioinfp_apps/Python-2.7.3/lib/python2.7/site-packages/wand/compat.py", line 44, in binary
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03a6' in position 0: ordinal not in range(128)
The reason is that in compat.py (https://github.com/dahlia/wand/blob/master/wand/compat.py#L44) we are currently doing a simple return 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:
Just my thoughts, you may of course do something else :-): then Wand maybe should not directly expose DrawSetTextEncoding, but rather use it internally and set it to UTF-8 (IM's docks say The only character encoding which may be specified at this time is "UTF-8"). Wand could require people to use unicode objects in Python code, which would then (internally, again) become encoded as UTF-8 before passing to ImageMagick.