Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1069

Black formatter for Python gives a decoding error "not a utf-8 character" - how can I tell black to use 'UTF-16'?

$
0
0

I added a magic header:

# -*- coding: utf-8 -*-

No change in the results.

Input file is created by intelliJ IDEA 2023.2.2.

Several files give the same error.

I see comments suggesting that utf-8 is standard encoding and trusted that intelliJ IDEA 2023.2.2 would mind the standard.

I removed the --diff tag, but still got the same results.

I'm on Windows 11, with Python 3.11.

I get this traceback:

E:\python\Projects\p2>python -m black --diff settings.pyTraceback (most recent call last):  File "<frozen runpy>", line 198, in _run_module_as_main  File "<frozen runpy>", line 88, in _run_code  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\black\__main__.py", line 3, in <module>    patched_main()  File "src\black\__init__.py", line 1602, in patched_main  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1157, in __call__    return self.main(*args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1078, in main    rv = self.invoke(ctx)         ^^^^^^^^^^^^^^^^  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1434, in invoke    return ctx.invoke(self.callback, **ctx.params)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 783, in invoke    return __callback(*args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\click\decorators.py", line 33, in new_func    return f(get_current_context(), *args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "src\black\__init__.py", line 668, in main  File "src\black\__init__.py", line 744, in get_sources  File "C:\Users\dickr\AppData\Roaming\Python\Python311\site-packages\black\files.py", line 254, in get_gitignore    lines = gf.readlines()            ^^^^^^^^^^^^^^  File "<frozen codecs>", line 322, in decodeUnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid continuation byte

I've searched black documentation for an option to change encoding with no luck.


Viewing all articles
Browse latest Browse all 1069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>