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: 'latin-1' codec can't encode characters in position 19-89: ordinal not in range(256) #94

Open
Short-bus opened this issue Nov 24, 2024 · 2 comments

Comments

@Short-bus
Copy link
Owner

This error appears if the Raspberry Pi does not have UTF-8 character set selected.

An example startup output...

Hostname: raspberrypi
Locale: ('en_US', 'ISO8859-1')
...
  File "/home/pi/pilomar/src/textcolor.py", line 409, in TextBox
    print(line)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 19-89: ordinal not in range(256)
@Short-bus
Copy link
Owner Author

The clue is in the output 'Locale: ('en_US', 'ISO8859-1').
The second item should be 'UTF-8'. Pi-lomar expects a UTF-8 environment.
In this case the operating system configuration is incorrect.
This can be fixed via the Raspberry Pi Configuration utility.
Go to the Localisation tab.
Select Set Locale.
Change the Character Set to UTF-8
Accept [OK] the changes then reboot the RPi.

The detection and error message will be improved in the next pi-lomar release.

@Short-bus
Copy link
Owner Author

Found that the main cause of failure are the special characters in the SYMBOLS dictionaries in src/pilomar.py and src/textcolor.py. These are the characters for linedrawing, arrows, degree symbol etc. If the program recognises that the locale character set is not UTF-8 it should be possible to select an alternative SYMBOLS dictionary which is restricted to 7bit ASCII characters only.

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

1 participant