We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
nbconvert: Unicode error with minus sign
Running
`ipython nbconvert --format="latex" odes_clean.ipynb`
I get a strange (to my mind) unicode error, which seems to be a minus sign, apparently in an SVG?

```
/bin/sh: /Applications/Inkscape.app/Contents/Resources/bin/inkscape: No such file or directory
/bin/sh: /Applications/Inkscape.app/Contents/Resources/bin/inkscape: No such file or directory
Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 6, in <module>
    start_ipython()
  File "/Users/dsanders/development/ipython/IPython/__init__.py", line 118, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/dsanders/development/ipython/IPython/config/application.py", line 539, in launch_instance
    app.start()
  File "/Users/dsanders/development/ipython/IPython/terminal/ipapp.py", line 362, in start
    return self.subapp.start()
  File "/Users/dsanders/development/ipython/IPython/nbconvert/nbconvertapp.py", line 176, in start
    self.convert_notebooks()
  File "/Users/dsanders/development/ipython/IPython/nbconvert/nbconvertapp.py", line 197, in convert_notebooks
    config=self.config)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 61, in decorator
    return f(*args, **kwargs)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 214, in export_by_name
    return globals()[function_name](nb, **kw)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 61, in decorator
    return f(*args, **kwargs)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 165, in export_latex
    return export(LatexExporter, nb, **kw)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 61, in decorator
    return f(*args, **kwargs)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py", line 122, in export
    output, resources = exporter_instance.from_filename(nb, resources)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py", line 221, in from_filename
    return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py", line 190, in from_notebook_node
    nb_copy, resources = self._transform(nb_copy, resources)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py", line 442, in _transform
    nbc, resc = transformer(nbc, resc)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/transformers/base.py", line 61, in __call__
    return self.call(nb,resources)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/transformers/base.py", line 85, in call
    worksheet.cells[index], resources = self.transform_cell(cell, resources, index)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/transformers/convertfigures.py", line 54, in transform_cell
    self._convert_figure(cell_out, resources, data_type, data)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/transformers/convertfigures.py", line 63, in _convert_figure
    data = self.convert_figure(data_type, data)
  File "/Users/dsanders/development/ipython/IPython/nbconvert/transformers/svg2pdf.py", line 77, in convert_figure
    f.write(data)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2212' in position 13282: ordinal not in range(128)
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/nbconvert/transformers/svg2pdf.py`
Content:
```
1 """Module containing a transformer that converts outputs in the notebook from 
2 one format to another.
3 """
4 #-----------------------------------------------------------------------------
5 # Copyright (c) 2013, the IPython Development Team.
6 #
7 # Distributed under the terms of the Modified BSD License.
8 #
9 # The full license is in the file COPYING.txt, distributed with this software.
10 #-----------------------------------------------------------------------------
11 
12 #-----------------------------------------------------------------------------
13 # Imports
14 #-----------------------------------------------------------------------------
15 
16 import base64
17 import os
18 import sys
19 import subprocess
20 
21 from IPython.utils.tempdir import TemporaryDirectory
22 from IPython.utils.traitlets import Unicode
23 
24 from .convertfigures import ConvertFiguresTransformer
25 
26 
27 #-----------------------------------------------------------------------------
28 # Constants
29 #-----------------------------------------------------------------------------
30 
31 INKSCAPE_COMMAND = 'inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
32 INKSCAPE_OSX_COMMAND = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
33 
34 
35 #-----------------------------------------------------------------------------
36 # Classes
37 #-----------------------------------------------------------------------------
38 
39 class SVG2PDFTransformer(ConvertFiguresTransformer):
40     """
41     Converts all of the outputs in a notebook from SVG to PDF.
42     """
43 
44     from_format = Unicode('svg', config=True, help='Format the converter accepts')
45     to_format = Unicode('pdf', config=False, help='Format the converter writes')
46     command = Unicode(config=True,
47         help="""The command to use for converting SVG to PDF
48         
49         This string is a template, which will be formatted with the keys
50         to_filename and from_filename.
51         
52         The conversion call must read the SVG from {from_flename},
53         and write a PDF to {to_filename}.
54         """)
55     
56     def _command_default(self):
57         if sys.platform == "darwin":
58             return INKSCAPE_OSX_COMMAND
59         elif sys.platform == "win32":
60             # windows not yet supported
61             return ""
62         else:
63             return INKSCAPE_COMMAND
64 
65 
66     def convert_figure(self, data_format, data):
67         """
68         Convert a single SVG figure to PDF.  Returns converted data.
69         """
70 
71         #Work in a temporary directory
72         with TemporaryDirectory() as tmpdir:
73             
74             #Write fig to temp file
75             input_filename = os.path.join(tmpdir, 'figure.' + data_format)
76             with open(input_filename, 'wb') as f:
77                 f.write(data)
78 
79             #Call conversion application
80             output_filename = os.path.join(tmpdir, 'figure.pdf')
81             shell = self.command.format(from_filename=input_filename, 
82                                    to_filename=output_filename)
83             subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.
84 
85             #Read output from drive
86             # return value expects a filename
87             if os.path.isfile(output_filename):
88                 with open(output_filename, 'rb') as f:
89                     # PDF is a nb supported binary, data type, so base64 encode.
90                     return base64.encodestring(f.read())
91             else:
92                 return TypeError("Inkscape svg to png conversion failed")
93
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/IPython/nbconvert/transformers/svg2pdf.py b/IPython/nbconvert/transformers/svg2pdf.py
--- a/IPython/nbconvert/transformers/svg2pdf.py
+++ b/IPython/nbconvert/transformers/svg2pdf.py
@@ -14,6 +14,7 @@
 #-----------------------------------------------------------------------------
 
 import base64
+import io
 import os
 import sys
 import subprocess
@@ -28,9 +29,7 @@
 # Constants
 #-----------------------------------------------------------------------------
 
-INKSCAPE_COMMAND = 'inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
-INKSCAPE_OSX_COMMAND = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --export-pdf="{to_filename}" "{from_filename}"'
-
+INKSCAPE_APP = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'
 
 #-----------------------------------------------------------------------------
 # Classes
@@ -43,6 +42,7 @@
 
     from_format = Unicode('svg', config=True, help='Format the converter accepts')
     to_format = Unicode('pdf', config=False, help='Format the converter writes')
+    
     command = Unicode(config=True,
         help="""The command to use for converting SVG to PDF
         
@@ -54,13 +54,15 @@
         """)
     
     def _command_default(self):
+        return self.inkscape + \
+               ' --without-gui --export-pdf="{to_filename}" "{from_filename}"'
+    
+    inkscape = Unicode(config=True, help="The path to Inkscape, if necessary")
+    def _inkscape_default(self):
         if sys.platform == "darwin":
-            return INKSCAPE_OSX_COMMAND
-        elif sys.platform == "win32":
-            # windows not yet supported
-            return ""
-        else:
-            return INKSCAPE_COMMAND
+            if os.path.isfile(INKSCAPE_APP):
+                return INKSCAPE_APP
+        return "inkscape"
 
 
     def convert_figure(self, data_format, data):
@@ -73,7 +75,8 @@
             
             #Write fig to temp file
             input_filename = os.path.join(tmpdir, 'figure.' + data_format)
-            with open(input_filename, 'wb') as f:
+            # SVG data is unicode text
+            with io.open(input_filename, 'w', encoding='utf8') as f:
                 f.write(data)
 
             #Call conversion application
@@ -89,4 +92,4 @@
                     # PDF is a nb supported binary, data type, so base64 encode.
                     return base64.encodestring(f.read())
             else:
-                return TypeError("Inkscape svg to png conversion failed")
+                raise TypeError("Inkscape svg to png conversion failed")

{"golden_diff": "diff --git a/IPython/nbconvert/transformers/svg2pdf.py b/IPython/nbconvert/transformers/svg2pdf.py\n--- a/IPython/nbconvert/transformers/svg2pdf.py\n+++ b/IPython/nbconvert/transformers/svg2pdf.py\n@@ -14,6 +14,7 @@\n #-----------------------------------------------------------------------------\n \n import base64\n+import io\n import os\n import sys\n import subprocess\n@@ -28,9 +29,7 @@\n # Constants\n #-----------------------------------------------------------------------------\n \n-INKSCAPE_COMMAND = 'inkscape --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\n-INKSCAPE_OSX_COMMAND = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\n-\n+INKSCAPE_APP = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'\n \n #-----------------------------------------------------------------------------\n # Classes\n@@ -43,6 +42,7 @@\n \n     from_format = Unicode('svg', config=True, help='Format the converter accepts')\n     to_format = Unicode('pdf', config=False, help='Format the converter writes')\n+    \n     command = Unicode(config=True,\n         help=\"\"\"The command to use for converting SVG to PDF\n         \n@@ -54,13 +54,15 @@\n         \"\"\")\n     \n     def _command_default(self):\n+        return self.inkscape + \\\n+               ' --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\n+    \n+    inkscape = Unicode(config=True, help=\"The path to Inkscape, if necessary\")\n+    def _inkscape_default(self):\n         if sys.platform == \"darwin\":\n-            return INKSCAPE_OSX_COMMAND\n-        elif sys.platform == \"win32\":\n-            # windows not yet supported\n-            return \"\"\n-        else:\n-            return INKSCAPE_COMMAND\n+            if os.path.isfile(INKSCAPE_APP):\n+                return INKSCAPE_APP\n+        return \"inkscape\"\n \n \n     def convert_figure(self, data_format, data):\n@@ -73,7 +75,8 @@\n             \n             #Write fig to temp file\n             input_filename = os.path.join(tmpdir, 'figure.' + data_format)\n-            with open(input_filename, 'wb') as f:\n+            # SVG data is unicode text\n+            with io.open(input_filename, 'w', encoding='utf8') as f:\n                 f.write(data)\n \n             #Call conversion application\n@@ -89,4 +92,4 @@\n                     # PDF is a nb supported binary, data type, so base64 encode.\n                     return base64.encodestring(f.read())\n             else:\n-                return TypeError(\"Inkscape svg to png conversion failed\")\n+                raise TypeError(\"Inkscape svg to png conversion failed\")\n", "issue": "nbconvert: Unicode error with minus sign\nRunning\n`ipython nbconvert --format=\"latex\" odes_clean.ipynb`\nI get a strange (to my mind) unicode error, which seems to be a minus sign, apparently in an SVG?\n\n```\n/bin/sh: /Applications/Inkscape.app/Contents/Resources/bin/inkscape: No such file or directory\n/bin/sh: /Applications/Inkscape.app/Contents/Resources/bin/inkscape: No such file or directory\nTraceback (most recent call last):\n  File \"/usr/local/bin/ipython\", line 6, in <module>\n    start_ipython()\n  File \"/Users/dsanders/development/ipython/IPython/__init__.py\", line 118, in start_ipython\n    return launch_new_instance(argv=argv, **kwargs)\n  File \"/Users/dsanders/development/ipython/IPython/config/application.py\", line 539, in launch_instance\n    app.start()\n  File \"/Users/dsanders/development/ipython/IPython/terminal/ipapp.py\", line 362, in start\n    return self.subapp.start()\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/nbconvertapp.py\", line 176, in start\n    self.convert_notebooks()\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/nbconvertapp.py\", line 197, in convert_notebooks\n    config=self.config)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 61, in decorator\n    return f(*args, **kwargs)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 214, in export_by_name\n    return globals()[function_name](nb, **kw)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 61, in decorator\n    return f(*args, **kwargs)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 165, in export_latex\n    return export(LatexExporter, nb, **kw)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 61, in decorator\n    return f(*args, **kwargs)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/export.py\", line 122, in export\n    output, resources = exporter_instance.from_filename(nb, resources)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py\", line 221, in from_filename\n    return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py\", line 190, in from_notebook_node\n    nb_copy, resources = self._transform(nb_copy, resources)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/exporters/exporter.py\", line 442, in _transform\n    nbc, resc = transformer(nbc, resc)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/transformers/base.py\", line 61, in __call__\n    return self.call(nb,resources)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/transformers/base.py\", line 85, in call\n    worksheet.cells[index], resources = self.transform_cell(cell, resources, index)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/transformers/convertfigures.py\", line 54, in transform_cell\n    self._convert_figure(cell_out, resources, data_type, data)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/transformers/convertfigures.py\", line 63, in _convert_figure\n    data = self.convert_figure(data_type, data)\n  File \"/Users/dsanders/development/ipython/IPython/nbconvert/transformers/svg2pdf.py\", line 77, in convert_figure\n    f.write(data)\nUnicodeEncodeError: 'ascii' codec can't encode character u'\\u2212' in position 13282: ordinal not in range(128)\n```\n\n", "before_files": [{"content": "\"\"\"Module containing a transformer that converts outputs in the notebook from \none format to another.\n\"\"\"\n#-----------------------------------------------------------------------------\n# Copyright (c) 2013, the IPython Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport base64\nimport os\nimport sys\nimport subprocess\n\nfrom IPython.utils.tempdir import TemporaryDirectory\nfrom IPython.utils.traitlets import Unicode\n\nfrom .convertfigures import ConvertFiguresTransformer\n\n\n#-----------------------------------------------------------------------------\n# Constants\n#-----------------------------------------------------------------------------\n\nINKSCAPE_COMMAND = 'inkscape --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\nINKSCAPE_OSX_COMMAND = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\n\n\n#-----------------------------------------------------------------------------\n# Classes\n#-----------------------------------------------------------------------------\n\nclass SVG2PDFTransformer(ConvertFiguresTransformer):\n    \"\"\"\n    Converts all of the outputs in a notebook from SVG to PDF.\n    \"\"\"\n\n    from_format = Unicode('svg', config=True, help='Format the converter accepts')\n    to_format = Unicode('pdf', config=False, help='Format the converter writes')\n    command = Unicode(config=True,\n        help=\"\"\"The command to use for converting SVG to PDF\n        \n        This string is a template, which will be formatted with the keys\n        to_filename and from_filename.\n        \n        The conversion call must read the SVG from {from_flename},\n        and write a PDF to {to_filename}.\n        \"\"\")\n    \n    def _command_default(self):\n        if sys.platform == \"darwin\":\n            return INKSCAPE_OSX_COMMAND\n        elif sys.platform == \"win32\":\n            # windows not yet supported\n            return \"\"\n        else:\n            return INKSCAPE_COMMAND\n\n\n    def convert_figure(self, data_format, data):\n        \"\"\"\n        Convert a single SVG figure to PDF.  Returns converted data.\n        \"\"\"\n\n        #Work in a temporary directory\n        with TemporaryDirectory() as tmpdir:\n            \n            #Write fig to temp file\n            input_filename = os.path.join(tmpdir, 'figure.' + data_format)\n            with open(input_filename, 'wb') as f:\n                f.write(data)\n\n            #Call conversion application\n            output_filename = os.path.join(tmpdir, 'figure.pdf')\n            shell = self.command.format(from_filename=input_filename, \n                                   to_filename=output_filename)\n            subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.\n\n            #Read output from drive\n            # return value expects a filename\n            if os.path.isfile(output_filename):\n                with open(output_filename, 'rb') as f:\n                    # PDF is a nb supported binary, data type, so base64 encode.\n                    return base64.encodestring(f.read())\n            else:\n                return TypeError(\"Inkscape svg to png conversion failed\")\n", "path": "IPython/nbconvert/transformers/svg2pdf.py"}], "after_files": [{"content": "\"\"\"Module containing a transformer that converts outputs in the notebook from \none format to another.\n\"\"\"\n#-----------------------------------------------------------------------------\n# Copyright (c) 2013, the IPython Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport base64\nimport io\nimport os\nimport sys\nimport subprocess\n\nfrom IPython.utils.tempdir import TemporaryDirectory\nfrom IPython.utils.traitlets import Unicode\n\nfrom .convertfigures import ConvertFiguresTransformer\n\n\n#-----------------------------------------------------------------------------\n# Constants\n#-----------------------------------------------------------------------------\n\nINKSCAPE_APP = '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'\n\n#-----------------------------------------------------------------------------\n# Classes\n#-----------------------------------------------------------------------------\n\nclass SVG2PDFTransformer(ConvertFiguresTransformer):\n    \"\"\"\n    Converts all of the outputs in a notebook from SVG to PDF.\n    \"\"\"\n\n    from_format = Unicode('svg', config=True, help='Format the converter accepts')\n    to_format = Unicode('pdf', config=False, help='Format the converter writes')\n    \n    command = Unicode(config=True,\n        help=\"\"\"The command to use for converting SVG to PDF\n        \n        This string is a template, which will be formatted with the keys\n        to_filename and from_filename.\n        \n        The conversion call must read the SVG from {from_flename},\n        and write a PDF to {to_filename}.\n        \"\"\")\n    \n    def _command_default(self):\n        return self.inkscape + \\\n               ' --without-gui --export-pdf=\"{to_filename}\" \"{from_filename}\"'\n    \n    inkscape = Unicode(config=True, help=\"The path to Inkscape, if necessary\")\n    def _inkscape_default(self):\n        if sys.platform == \"darwin\":\n            if os.path.isfile(INKSCAPE_APP):\n                return INKSCAPE_APP\n        return \"inkscape\"\n\n\n    def convert_figure(self, data_format, data):\n        \"\"\"\n        Convert a single SVG figure to PDF.  Returns converted data.\n        \"\"\"\n\n        #Work in a temporary directory\n        with TemporaryDirectory() as tmpdir:\n            \n            #Write fig to temp file\n            input_filename = os.path.join(tmpdir, 'figure.' + data_format)\n            # SVG data is unicode text\n            with io.open(input_filename, 'w', encoding='utf8') as f:\n                f.write(data)\n\n            #Call conversion application\n            output_filename = os.path.join(tmpdir, 'figure.pdf')\n            shell = self.command.format(from_filename=input_filename, \n                                   to_filename=output_filename)\n            subprocess.call(shell, shell=True) #Shell=True okay since input is trusted.\n\n            #Read output from drive\n            # return value expects a filename\n            if os.path.isfile(output_filename):\n                with open(output_filename, 'rb') as f:\n                    # PDF is a nb supported binary, data type, so base64 encode.\n                    return base64.encodestring(f.read())\n            else:\n                raise TypeError(\"Inkscape svg to png conversion failed\")\n", "path": "IPython/nbconvert/transformers/svg2pdf.py"}]}