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

German characters like Ö, ö, Ü, ü, Ä, ä, ß. #8

Open
HansvY opened this issue Dec 19, 2021 · 2 comments
Open

German characters like Ö, ö, Ü, ü, Ä, ä, ß. #8

HansvY opened this issue Dec 19, 2021 · 2 comments

Comments

@HansvY
Copy link

HansvY commented Dec 19, 2021

Hallo Shenghao,

Thanks for the good work! I'm currently using pylcddc in a project. However I find that I cannot send German characters like Ö, ö, Ü, ü, Ä, ä, and ß. Currently I use "unidecode()" as a workaround, which replace Ö with O, ö with o etc. I don't like it very much, as for example "G.F. Händel" becomes "G.F. Handel". (On Kodi/Libreelec I do get those characters on my display, so it must be possible somehow.)

Error msg:
pi@LCD-Raspberry:~ $ ./test-logging-test-rotating-spieldauer.py
Traceback (most recent call last):
File "/home/pi/./test-logging-test-rotating-spieldauer.py", line 161, in
main()
File "/home/pi/./test-logging-test-rotating-spieldauer.py", line 98, in main
LCD_UNTEN.text = werk
File "/home/pi/.local/lib/python3.9/site-packages/pylcddc/widgets.py", line 789, in text
self._validate_input(self.x, self.y, self.width, self.height,
File "/home/pi/.local/lib/python3.9/site-packages/pylcddc/widgets.py", line 674, in _validate_input
raise ValueError(f'invalid character in text: {ch!r}')
ValueError: invalid character in text: 'ü'

Could you please have a look?

Regards,
Hans

@shenghaoyang
Copy link
Owner

shenghaoyang commented Dec 20, 2021

Hello,

There is a validation step that rejects characters that are not contained within ACCEPTABLE_CHARACTERS:

ACCEPTABLE_CHARACTERS: str = (string.ascii_letters + string.punctuation

This was added because some LCDs multiplex command and display data over the same channel - a user could inadvertently send command sequences and mutate the (non display) state of their LCD because most LCDd drivers pass data directly to the display.

The umlauts are likely rendered by Kodi sending them using the ISO/IEC 8859-1 character set. Unfortunately, pylcddc only accepts strings at the moment and does not allow changing character encodings (the default is UTF-8), so expanding ACCEPTABLE_CHARACTERS won't really fix the issue.

I'll likely make all the text regions accept both raw bytes and str instead of only str so that users can choose their encodings (if they want to display non ASCII characters).

Does that sound like it'll fix your issue?

Shenghao

@HansvY
Copy link
Author

HansvY commented Dec 20, 2021

Hallo Shenghao,
I was thinking of editing Line 36 in widgets.py, but I get your point, that will not fix the issue.
I hope you find the time to make it possible to send raw bytes. Thanks in advance!
Cheers,
Hans

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