Permalink
Browse files

qtconsole export xhtml/utf8

	using utf-8 to save the qtconsole export as xhtml/svg, to avoid crash on some
	kinds of plots, mainly when converting svg to str, or when writing the file

	closes #1087
  • Loading branch information...
1 parent a3ee8de commit 3b6bc650332710225bee25c5f37f4a4b6bafae11 @Carreau committed Dec 4, 2011
Showing with 5 additions and 3 deletions.
  1. +1 −1 IPython/frontend/qt/console/rich_ipython_widget.py
  2. +4 −2 IPython/frontend/qt/rich_text.py
@@ -198,7 +198,7 @@ def _get_image_tag(self, match, path = None, format = "png"):
elif format == "svg":
try:
- svg = str(self._name_to_svg_map[match.group("name")])
+ svg = self._name_to_svg_map[match.group("name")]
except KeyError:
return "<b>Couldn't find image %s</b>" % match.group("name")
@@ -7,6 +7,7 @@
# Standard library imports.
import os
import re
+import codecs
# System library imports.
from IPython.external.qt import QtGui
@@ -182,8 +183,9 @@ def export_xhtml(html, filename, image_tag=None):
html[offset+6:])
html = fix_html(html)
- f.write(IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"),
- html))
+ sub=IMG_RE.sub(lambda x: image_tag(x, path = None, format = "svg"), html)
+ f.write( codecs.BOM_UTF8 )
+ f.write( sub.encode("utf-8") )
def default_image_tag(match, path = None, format = "png"):

0 comments on commit 3b6bc65

Please sign in to comment.