Changed unconvertable-character symbol to ¿ and made it return only one per unconvertable sequence

This commit is contained in:
Professr 2020-06-23 16:46:41 -07:00
parent 70a8fe30b7
commit 2530dc44c7

View File

@ -154,9 +154,11 @@ class Screen : public PeriodicTask
// UTF-8 to font table index converter // UTF-8 to font table index converter
// Code form http://playground.arduino.cc/Main/Utf8ascii // Code form http://playground.arduino.cc/Main/Utf8ascii
static uint8_t LASTCHAR; static uint8_t LASTCHAR;
static bool SKIPREST; // Only display a single unconvertable-character symbol per sequence of unconvertable characters
if (ch < 128) { // Standard ASCII-set 0..0x7F handling if (ch < 128) { // Standard ASCII-set 0..0x7F handling
LASTCHAR = 0; LASTCHAR = 0;
SKIPREST = false;
return ch; return ch;
} }
@ -164,12 +166,15 @@ class Screen : public PeriodicTask
LASTCHAR = ch; LASTCHAR = ch;
switch (last) { // conversion depnding on first UTF8-character switch (last) { // conversion depnding on first UTF8-character
case 0xC2: return (uint8_t) ch; case 0xC2: { SKIPREST = false; return (uint8_t) ch; }
case 0xC3: return (uint8_t) (ch | 0xC0); case 0xC3: { SKIPREST = false; return (uint8_t) (ch | 0xC0); }
case 0x82: if (ch == 0xAC) return (uint8_t) 0x80; // special case Euro-symbol case 0x82: { SKIPREST = false; if (ch == 0xAC) return (uint8_t) 0x80; } // special case Euro-symbol
} }
// If we already returned an unconvertable-character symbol for this unconvertable-character sequence, return NULs for the rest of it
if (SKIPREST) return (uint8_t) 0;
SKIPREST = true;
return (uint8_t) '?'; // otherwise: return ?, if character can't be converted return (uint8_t) 0xA8; // otherwise: return ¿ if character can't be converted
} }
/// Returns a handle to the DebugInfo screen. /// Returns a handle to the DebugInfo screen.