Open HansvY opened 2 years ago
Hello,
There is a validation step that rejects characters that are not contained within ACCEPTABLE_CHARACTERS
: https://github.com/shenghaoyang/pylcddc/blob/5aac5434cf660a02d0b4d8573cc1637f22f0accf/pylcddc/widgets.py#L36
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
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
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