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

UnicodeDecodeError under Japanese envrionment #21

Closed
tkhrmeme opened this issue Nov 14, 2018 · 1 comment
Closed

UnicodeDecodeError under Japanese envrionment #21

tkhrmeme opened this issue Nov 14, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@tkhrmeme
Copy link

Hello!

I encountered UnicodeDecodeError under Windows10; Japanese version.

I think there is a need to add encoding='UTF-8' when opening a SVG file at line 51 of utils.py.

UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-20-f25891910720> in <module>()
      6                class_names=['Safe', 'Bad'])
      7 
----> 8 viz.view()

c:\users\takahiro_endo\venv64\lib\site-packages\dtreeviz\trees.py in view(self)
     64         tmp = tempfile.gettempdir()
     65         svgfilename = f"{tmp}/DTreeViz_{getpid()}.svg"
---> 66         self.save(svgfilename)
     67         view(svgfilename)
     68 

c:\users\takahiro_endo\venv64\lib\site-packages\dtreeviz\trees.py in save(self, filename)
    101             with open(filename, encoding='UTF-8') as f:
    102                 svg = f.read()
--> 103             svg = inline_svg_images(svg)
    104             with open(filename, "w", encoding='UTF-8') as f:
    105                 f.write(svg)

c:\users\takahiro_endo\venv64\lib\site-packages\dtreeviz\utils.py in inline_svg_images(svg)
     50         svgfilename = img.attrib["{http://www.w3.org/1999/xlink}href"]
     51         with open(svgfilename) as f:
---> 52             imgsvg = f.read()
     53         imgroot = ET.fromstring(imgsvg)
     54         for k,v in img.attrib.items(): # copy IMAGE tag attributes to svg from image file

UnicodeDecodeError: 'cp932' codec can't decode byte 0x92 in position 1079: illegal multibyte sequence

@wenyanghan
Copy link

I just fix like
with open(svgfilename,encoding='UTF-8') as f:

@parrt parrt closed this as completed in 7d8efc4 May 26, 2019
@parrt parrt added the bug Something isn't working label May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants