mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
simple_display: replace umlauts with visible characters
The SPARK VFD/LED cannot display umlauts, so add a crude function that replaces the most common ones with characters that can be displayed. TODO: test on azboxme.
This commit is contained in:
@@ -76,6 +76,29 @@ static inline int led_open()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void replace_umlauts(std::string &s)
|
||||||
|
{
|
||||||
|
/* this is crude, it just replaces ÄÖÜ with AOU since the display can't show them anyway */
|
||||||
|
/* Ä ä Ö ö Ü ü */
|
||||||
|
char tofind[][3] = { "\xc3\x84", "\xc3\xa4", "\xc3\x96", "\xc3\xb6", "\xc3\x9c", "\xc3\xbc" };
|
||||||
|
char toreplace[] = { "AaOoUu" };
|
||||||
|
char repl[2];
|
||||||
|
repl[1] = '\0';
|
||||||
|
int i = 0;
|
||||||
|
size_t pos;
|
||||||
|
// print("%s:>> '%s'\n", __func__, s.c_str());
|
||||||
|
while (toreplace[i] != 0x0) {
|
||||||
|
pos = s.find(tofind[i]);
|
||||||
|
if (pos == std::string::npos) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
repl[0] = toreplace[i];
|
||||||
|
s.replace(pos, 2, std::string(repl));
|
||||||
|
}
|
||||||
|
// printf("%s:<< '%s'\n", __func__, s.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
static void display(const char *s, bool update_timestamp = true)
|
static void display(const char *s, bool update_timestamp = true)
|
||||||
{
|
{
|
||||||
int fd = dev_open();
|
int fd = dev_open();
|
||||||
@@ -164,6 +187,7 @@ void CLCD::showServicename(std::string name, bool)
|
|||||||
servicename = name;
|
servicename = name;
|
||||||
if (mode != MODE_TVRADIO)
|
if (mode != MODE_TVRADIO)
|
||||||
return;
|
return;
|
||||||
|
replace_umlauts(servicename);
|
||||||
strncpy(display_text, servicename.c_str(), sizeof(display_text) - 1);
|
strncpy(display_text, servicename.c_str(), sizeof(display_text) - 1);
|
||||||
display_text[sizeof(display_text) - 1] = '\0';
|
display_text[sizeof(display_text) - 1] = '\0';
|
||||||
upd_display = true;
|
upd_display = true;
|
||||||
@@ -330,7 +354,9 @@ void CLCD::showMenuText(const int, const char *text, const int, const bool)
|
|||||||
{
|
{
|
||||||
if (mode != MODE_MENU_UTF8)
|
if (mode != MODE_MENU_UTF8)
|
||||||
return;
|
return;
|
||||||
strncpy(display_text, text, sizeof(display_text) - 1);
|
std::string tmp = text;
|
||||||
|
replace_umlauts(tmp);
|
||||||
|
strncpy(display_text, tmp.c_str(), sizeof(display_text) - 1);
|
||||||
display_text[sizeof(display_text) - 1] = '\0';
|
display_text[sizeof(display_text) - 1] = '\0';
|
||||||
upd_display = true;
|
upd_display = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user