UnicodeEncodeError in qt.svg.save_svg #489

Closed
mspacek opened this Issue Jun 1, 2011 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

mspacek commented Jun 1, 2011

Matplotlib defaults to "axes.unicode_minus : True", which means plots with minus signs in them that you try to save to svg have at least that one unicode character. Running ipython-qtconsole --pylab=inline, typing plot(range(-1, 10)), right clicking the image, and saving it as svg results in:

Traceback (most recent call last):
  File "/home/mspacek/source/ipython/IPython/frontend/qt/console/rich_ipython_widget.py", line 60, in <lambda>
    lambda: save_svg(svg, self._control))
  File "/home/mspacek/source/ipython/IPython/frontend/qt/svg.py", line 32, in save_svg
    f.write(string)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2212' in position 12271: ordinal not in range(128)

I guess the svg string needs to be encoded in UTF-8 before being written to file.

minrk closed this in 5acdcc1 Jun 1, 2011

minrk closed this in 6a0fa99 Jun 1, 2011

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

@mspacek mspacek fix UnicodeEncodeError writing SVG string to .svg file, fixes #489 9fdc562

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

@minrk minrk Merge pull request #490 from mspacek/svg-unicode
fix UnicodeEncodeError writing SVG string to .svg file
 
closes gh-489
5eb37f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment