google / vimdoc

Helpfile generation for vim
Apache License 2.0
291 stars 28 forks source link

Get UnicodeDecodeError when using this plugin in windows 7 #104

Closed wsdjeg closed 5 years ago

wsdjeg commented 5 years ago

when using this tool in window 7, I get:

C:\Users\Administrator\.SpaceVim>python -m vimdoc .
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\vimdoc\__main__.py", line 22, in <module>
    main()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\vimdoc\__main__.py", line 18, in main
    for module in Modules(args.plugin):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\vimdoc\module.py", line 421, in Modules
    lines = list(filehandle)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x96 in position 2806: illegal multibyte sequence
wsdjeg commented 5 years ago

I change line 420 in vimdoc/module.py to

        with open(filename, encoding='utf-8') as filehandle:

then it works well.

dbarnett commented 5 years ago

Thanks for reporting! Should be fixed now in #105.

Passed explicit encoding there and a few other places we were opening files.

wsdjeg commented 5 years ago

Thanks for your work. :)