Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UTF-8 encoding #2

Closed
demberto opened this issue Oct 26, 2022 · 1 comment
Closed

Support UTF-8 encoding #2

demberto opened this issue Oct 26, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@demberto
Copy link

SVGBob supports UTF-8 box drawing characters, which arguably look a lot better than what ASCII looks like in a (modern) text editor.

I think you need to explicitly add an encoding="utf-8" here:

with open(outfile, mode="w") as f:

based on the tracebox in the error log Sphinx created:

Traceback (most recent call last):
  File "venv\lib\site-packages\sphinx\cmd\build.py", line 277, in build_main
    app.build(args.force_all, filenames)
  File "venv\lib\site-packages\sphinx\application.py", line 349, in build
    self.builder.build_update()
  File "venv\lib\site-packages\sphinx\builders\__init__.py", line 301, in build_update
    self.build(to_build,
  File "venv\lib\site-packages\sphinx\builders\__init__.py", line 317, in build
    updated_docnames = set(self.read())
  File "venv\lib\site-packages\sphinx\builders\__init__.py", line 424, in read
    self._read_serial(docnames)
  File "venv\lib\site-packages\sphinx\builders\__init__.py", line 445, in _read_serial
    self.read_doc(docname)
  File "venv\lib\site-packages\sphinx\builders\__init__.py", line 498, in read_doc
    publisher.publish()
  File "venv\lib\site-packages\docutils\core.py", line 219, in publish
    self.apply_transforms()
  File "venv\lib\site-packages\docutils\core.py", line 200, in apply_transforms
    self.document.transformer.apply_transforms()
  File "venv\lib\site-packages\sphinx\transforms\__init__.py", line 80, in apply_transforms
    super().apply_transforms()
  File "venv\lib\site-packages\docutils\transforms\__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "venv\lib\site-packages\sphinxcontrib\svgbob\transform.py", line 45, in apply
    out = self.render(node, options)
  File "venv\lib\site-packages\sphinxcontrib\svgbob\transform.py", line 69, in render
    f.write(to_svg(node["code"], **options)) # type: ignore
  File "Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2192' in position 2864: character maps to <undefined>
@althonos
Copy link
Member

Hi @demberto , thanks for the heads-up. The new release should now support Unicode box characters, and I've added a unit test to explicitly check that as well.

@althonos althonos added the enhancement New feature or request label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants