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

UnicodeEncodeError: 'charmap' codec can't encode character '\u274c' in position 1636: character maps to <undefined> #113

Open
ylli2000 opened this issue Oct 13, 2024 · 2 comments

Comments

@ylli2000
Copy link

What:
I use a few emojis in my code, green check, red cross...etc. '\u274c' is literally the Unicode for ❌

Error:

Traceback (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\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\pyminify.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\python_minifier\__main__.py", line 76, in main
    sys.stdout.write(minified)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\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 '\u274c' in position 1636: character maps to <undefined>

Expect:
I am expecting the minifier to be able to handle Unicode like this without error.

Versioning:
python_minifier-2.11.2
Python 3.12.7

@dflook
Copy link
Owner

dflook commented Oct 13, 2024

Unfortunately, Python on Windows is broken by default. See #57.

Could you set the environment variable PYTHONUTF8=1 and see if it works?

@ylli2000
Copy link
Author

Works! Thank you :)

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