Allow print a string with some umlauts characters.#190
Allow print a string with some umlauts characters.#190matinicolosi wants to merge 1 commit intoadafruit:masterfrom
Conversation
|
This code does not achieve the desired result in a reasonable way, and makes the API confused. BackgroundThe Adafruit_GFX library (not this library) is responsible for mapping characters in strings to glyphs. Adafruit_GFX uses Code Page 437 as the encoding. As such, it correctly maps bytes that encode umlauted characters to the proper glyph, and displays correctly. It handles all the umlauted characters mentioned in this patch. Adafruit_GFX's API requires that strings passed to it are encoded in CP437[*]. The Proposed CodeThe proposed code is a change to Adafruit_SSD1306. But this library is just the display driver for a particular set of displays. The code code for character interpretation is in Adafruit_GFX, and any change for character encodings belongs there. As you can see from the proposed code, its aim is to convert umlauted characters into their Code Page 437 encoded equivalents. For example: result.replace("ä", "\204");The string Thus, the proposed code amounts to a partial re-encoding of a SuggestionThis code doesn't belong in this library (which deals only with a specific display driver), nor in Adafruit_GFX. These libraries are clear in that they deal with strings in CP 437. In general - there is no presumption that arbitrary The proposed code is useful for someone who handles ISO 8859-1 encoded data, but it should placed in a library on it's own, with just the function of converting from ISO 8859-1 to CP 437. If done this way, it is more generally useful, doesn't muddy the API of these libraries, and could do a more complete encoding conversion. [*] There is a well known bug in Adafruit_GFX that original character tables had a bug which made the encoding wrong above |
I added a function that allow print a string with some umlauts characters.