how do I implement a custom code page used by a serial device so I can convert text to it in Python?
https://stackoverflow.com/questions/235416
Question
I have a scrolling LED sign that takes messages in either ASCII or (using some specific code) characters from a custom code page.
For example, the euro sign should be sent as
<U00>
and ä is
<U64>
(You can find the full code page in the documentation)
My question is, what is the most pythonic way to implement this custom code page, and to have a codec that can convert UTF strings to my custom code page ?
Solution
- Pick a name for your encoding, maybe "led_display", whatever.
- Implement and register a codec with the standard library.
- Pythonic profit!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow