We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Escape unicode characters when producing latex
Currently, the qcircuit to latex code passes through unicode characters like ↺ ↻. LaTeX may not be happy about this. We should replace the unicode characters with some that LaTeX is happy with. Or perhaps throw an error?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cirq/contrib/qcircuit/qcircuit_pdf.py`
Content:
```
1 # Copyright 2018 The Cirq Developers
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 # coverage: ignore
16 
17 import errno
18 import os
19 
20 from pylatex import Document, NoEscape, Package
21 
22 from cirq import circuits
23 from cirq.contrib.qcircuit.qcircuit_diagram import (
24         circuit_to_latex_using_qcircuit)
25 
26 
27 def circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,
28                                           filepath: str,
29                                           pdf_kwargs=None,
30                                           qcircuit_kwargs=None,
31                                           clean_ext=('dvi', 'ps'),
32                                           documentclass='article'):
33     """Compiles the QCircuit-based latex diagram of the given circuit.
34 
35     Args:
36         circuit: The circuit to produce a pdf of.
37         filepath: Where to output the pdf.
38         pdf_kwargs: The arguments to pass to generate_pdf.
39         qcircuit_kwargs: The arguments to pass to
40             circuit_to_latex_using_qcircuit.
41         clean_ext: The file extensions to clean up after compilation. By
42             default, latexmk is used with the '-pdfps' flag, which produces
43             intermediary dvi and ps files.
44         documentclass: The documentclass of the latex file.
45     """
46     pdf_kwargs = {'compiler': 'latexmk', 'compiler_args': ['-pdfps'],
47                   **({} if pdf_kwargs is None else pdf_kwargs)}
48     qcircuit_kwargs = {} if qcircuit_kwargs is None else qcircuit_kwargs
49     tex = circuit_to_latex_using_qcircuit(circuit, **qcircuit_kwargs)
50     doc = Document(documentclass=documentclass, document_options='dvips')
51     doc.packages.append(Package('amsmath'))
52     doc.packages.append(Package('qcircuit'))
53     doc.append(NoEscape(tex))
54     doc.generate_pdf(filepath, **pdf_kwargs)
55     for ext in clean_ext:
56         try:
57             os.remove(filepath + '.' + ext)
58         except (OSError, IOError) as e:
59             if e.errno != errno.ENOENT:
60                 raise
61
```
--- 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/cirq/contrib/qcircuit/qcircuit_pdf.py b/cirq/contrib/qcircuit/qcircuit_pdf.py
--- a/cirq/contrib/qcircuit/qcircuit_pdf.py
+++ b/cirq/contrib/qcircuit/qcircuit_pdf.py
@@ -50,6 +50,7 @@
     doc = Document(documentclass=documentclass, document_options='dvips')
     doc.packages.append(Package('amsmath'))
     doc.packages.append(Package('qcircuit'))
+    doc.preamble.append(Package('inputenc', options=['utf8']))
     doc.append(NoEscape(tex))
     doc.generate_pdf(filepath, **pdf_kwargs)
     for ext in clean_ext:

{"golden_diff": "diff --git a/cirq/contrib/qcircuit/qcircuit_pdf.py b/cirq/contrib/qcircuit/qcircuit_pdf.py\n--- a/cirq/contrib/qcircuit/qcircuit_pdf.py\n+++ b/cirq/contrib/qcircuit/qcircuit_pdf.py\n@@ -50,6 +50,7 @@\n     doc = Document(documentclass=documentclass, document_options='dvips')\n     doc.packages.append(Package('amsmath'))\n     doc.packages.append(Package('qcircuit'))\n+    doc.preamble.append(Package('inputenc', options=['utf8']))\n     doc.append(NoEscape(tex))\n     doc.generate_pdf(filepath, **pdf_kwargs)\n     for ext in clean_ext:\n", "issue": "Escape unicode characters when producing latex\nCurrently, the qcircuit to latex code passes through unicode characters like \u21ba \u21bb. LaTeX may not be happy about this. We should replace the unicode characters with some that LaTeX is happy with. Or perhaps throw an error?\n", "before_files": [{"content": "# Copyright 2018 The Cirq Developers\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# coverage: ignore\n\nimport errno\nimport os\n\nfrom pylatex import Document, NoEscape, Package\n\nfrom cirq import circuits\nfrom cirq.contrib.qcircuit.qcircuit_diagram import (\n        circuit_to_latex_using_qcircuit)\n\n\ndef circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,\n                                          filepath: str,\n                                          pdf_kwargs=None,\n                                          qcircuit_kwargs=None,\n                                          clean_ext=('dvi', 'ps'),\n                                          documentclass='article'):\n    \"\"\"Compiles the QCircuit-based latex diagram of the given circuit.\n\n    Args:\n        circuit: The circuit to produce a pdf of.\n        filepath: Where to output the pdf.\n        pdf_kwargs: The arguments to pass to generate_pdf.\n        qcircuit_kwargs: The arguments to pass to\n            circuit_to_latex_using_qcircuit.\n        clean_ext: The file extensions to clean up after compilation. By\n            default, latexmk is used with the '-pdfps' flag, which produces\n            intermediary dvi and ps files.\n        documentclass: The documentclass of the latex file.\n    \"\"\"\n    pdf_kwargs = {'compiler': 'latexmk', 'compiler_args': ['-pdfps'],\n                  **({} if pdf_kwargs is None else pdf_kwargs)}\n    qcircuit_kwargs = {} if qcircuit_kwargs is None else qcircuit_kwargs\n    tex = circuit_to_latex_using_qcircuit(circuit, **qcircuit_kwargs)\n    doc = Document(documentclass=documentclass, document_options='dvips')\n    doc.packages.append(Package('amsmath'))\n    doc.packages.append(Package('qcircuit'))\n    doc.append(NoEscape(tex))\n    doc.generate_pdf(filepath, **pdf_kwargs)\n    for ext in clean_ext:\n        try:\n            os.remove(filepath + '.' + ext)\n        except (OSError, IOError) as e:\n            if e.errno != errno.ENOENT:\n                raise\n", "path": "cirq/contrib/qcircuit/qcircuit_pdf.py"}], "after_files": [{"content": "# Copyright 2018 The Cirq Developers\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# coverage: ignore\n\nimport errno\nimport os\n\nfrom pylatex import Document, NoEscape, Package\n\nfrom cirq import circuits\nfrom cirq.contrib.qcircuit.qcircuit_diagram import (\n        circuit_to_latex_using_qcircuit)\n\n\ndef circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,\n                                          filepath: str,\n                                          pdf_kwargs=None,\n                                          qcircuit_kwargs=None,\n                                          clean_ext=('dvi', 'ps'),\n                                          documentclass='article'):\n    \"\"\"Compiles the QCircuit-based latex diagram of the given circuit.\n\n    Args:\n        circuit: The circuit to produce a pdf of.\n        filepath: Where to output the pdf.\n        pdf_kwargs: The arguments to pass to generate_pdf.\n        qcircuit_kwargs: The arguments to pass to\n            circuit_to_latex_using_qcircuit.\n        clean_ext: The file extensions to clean up after compilation. By\n            default, latexmk is used with the '-pdfps' flag, which produces\n            intermediary dvi and ps files.\n        documentclass: The documentclass of the latex file.\n    \"\"\"\n    pdf_kwargs = {'compiler': 'latexmk', 'compiler_args': ['-pdfps'],\n                  **({} if pdf_kwargs is None else pdf_kwargs)}\n    qcircuit_kwargs = {} if qcircuit_kwargs is None else qcircuit_kwargs\n    tex = circuit_to_latex_using_qcircuit(circuit, **qcircuit_kwargs)\n    doc = Document(documentclass=documentclass, document_options='dvips')\n    doc.packages.append(Package('amsmath'))\n    doc.packages.append(Package('qcircuit'))\n    doc.preamble.append(Package('inputenc', options=['utf8']))\n    doc.append(NoEscape(tex))\n    doc.generate_pdf(filepath, **pdf_kwargs)\n    for ext in clean_ext:\n        try:\n            os.remove(filepath + '.' + ext)\n        except (OSError, IOError) as e:\n            if e.errno != errno.ENOENT:\n                raise\n", "path": "cirq/contrib/qcircuit/qcircuit_pdf.py"}]}