Skip to content

Conversation

@tonyjurg
Copy link
Contributor

@tonyjurg tonyjurg commented Dec 2, 2024

Importing beta_code in an Anaconda environment running on a Windows system results in the following error:

UnicodeDecodeError                        Traceback (most recent call last)
Cell In[1], line 1
----> 1 import beta_code

File ~\anaconda3\envs\CLTK-env\lib\site-packages\beta_code\__init__.py:1
----> 1 from .beta_code import greek_to_beta_code, beta_code_to_greek
      3 name = "beta_code"
...
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 54: character maps to <undefined>

This error occurs because the JSON files are loaded using the default Windows system encoding (cp1252) instead of UTF-8. Although the JSON data files are correctly encoded in UTF-8, the code does not explicitly specify this encoding when reading the files.

To resolve this issue, modify the beta_code.py file to explicitly declare UTF-8 encoding when opening the JSON files. This change ensures the library loads correctly and prevents the UnicodeDecodeError.

Modify the part of the beta_code.py file that opens the JSON files, explicitly specifying their encoding ( utf-8).
@zfletch
Copy link
Member

zfletch commented Dec 7, 2024

Thank you for fixing this! I hope the bug didn't cause you too much trouble.

@zfletch zfletch merged commit 196b643 into perseids-tools:master Dec 7, 2024
3 checks passed
@zfletch
Copy link
Member

zfletch commented Dec 7, 2024

I've just pushed a new version (1.1.1) with the change.

@tonyjurg tonyjurg deleted the utf-windows branch December 8, 2024 08:42
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

Successfully merging this pull request may close these issues.

2 participants