Permalink
Browse files

check for unicode before encoding as UTF-8

  • Loading branch information...
1 parent 5acdcc1 commit 35fb6d87bfd8999ebe8d60fc2376851026a4f886 @mspacek mspacek committed Jun 1, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 IPython/frontend/qt/svg.py
@@ -21,6 +21,9 @@ def save_svg(string, parent=None):
The name of the file to which the document was saved, or None if the save
was cancelled.
"""
+ if isinstance(string, unicode):
+ string = string.encode('utf-8')
+
dialog = QtGui.QFileDialog(parent, 'Save SVG Document')
dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
dialog.setDefaultSuffix('svg')
@@ -29,7 +32,7 @@ def save_svg(string, parent=None):
filename = dialog.selectedFiles()[0]
f = open(filename, 'w')
try:
- f.write(string.encode('UTF-8'))
+ f.write(string)
finally:
f.close()
return filename

0 comments on commit 35fb6d8

Please sign in to comment.