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

Thrown UnicodeEncodeError in non-English language windows environment #5

Open
huruka opened this issue May 29, 2022 · 1 comment
Open

Comments

@huruka
Copy link

huruka commented May 29, 2022

When bean file contains special characters that are beyond the scope of ASCII,running script thrown error as below:

>bean-black xxx.bean
Traceback (most recent call last):
  File "C:\Users\python\current\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\python\current\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\python\current\Scripts\bean-black.exe\__main__.py", line 7, in <module>
  File "C:\Users\python\current\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\python\current\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\python\current\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\python\current\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\python\current\lib\site-packages\beancount_black\main.py", line 49, in main
    formatter.format(tree, output_file)
  File "C:\Users\python\current\lib\site-packages\beancount_black\formatter.py", line 576, in format
    output_file.write("\n\n".join(sections))
  File "C:\Users\python\current\lib\tempfile.py", line 483, in func_wrapper
    return func(*args, **kwargs)
UnicodeEncodeError: 'gbk' codec can't encode character '\xa5' in position 211620: illegal multibyte sequence

But the file is saved in utf-8 encoding.
Then I try to write simple script that use the open function to write, it can be saved normally.

@fangpenlin
Copy link
Contributor

Can you provide a sample file for reproducing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants