how do I implement a custom code page used by a serial device so I can convert text to it in Python?

StackOverflow https://stackoverflow.com/questions/235416

  •  04-07-2019
  •  | 
  •  

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 ?

Was it helpful?

Solution

  1. Pick a name for your encoding, maybe "led_display", whatever.
  2. Implement and register a codec with the standard library.
  3. Pythonic profit!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top