Skip to content

Commit

Permalink
check for unicode before encoding as UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
mspacek committed Jun 1, 2011
1 parent 5acdcc1 commit 35fb6d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion IPython/frontend/qt/svg.py
Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 35fb6d8

Please sign in to comment.