ESP32-Radio
ESP32-Radio copied to clipboard
Extend utf8ascii function
Extended utf8ascii
function for 0xC4
and 0xC5
UTF-8 characters.
source
char utf8ascii ( char ascii )
{
static const char lut_C3[] = { "AAAAAAACEEEEIIIIDNOOOOO#0UUUU###"
"aaaaaaaceeeeiiiidnooooo##uuuuyyy" } ;
static const char lut_C4[] = { "AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGg"
"GgGgHhHhIiIiIiIiIiJjJjKkkLlLlLlL" } ;
static const char lut_C5[] = { "lLlNnNnNnnnnOoOoOoOoRrRrRrSsSsSs"
"SsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs" } ;
static char c1 ; // Last character buffer
char res = '\0' ; // Result, default 0
if ( ascii <= 0x7F ) // Standard ASCII-set 0..0x7F handling
{
c1 = 0 ;
res = ascii ; // Return unmodified
}
else
{
switch ( c1 ) // Conversion depending on first UTF8-character
{
case 0xC2: res = '~' ;
break ;
case 0xC3: res = lut_C3[ascii - 128] ;
break ;
case 0xC4: res = lut_C4[ascii - 128] ;
break ;
case 0xC5: res = lut_C5[ascii - 128] ;
break ;
case 0x82: if ( ascii == 0xAC )
{
res = 'E' ; // Special case Euro-symbol
}
}
c1 = ascii ; // Remember actual character
}
return res ; // Otherwise: return zero, if character has to be ignored
}
@Edzelf can you add it to your code?
I will include it in the V2 version of the software.