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.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 3ecbdb76c5
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2012-11-04 (Sun, 04 Nov 2012)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2012-11-04 18:42:59 +01:00
parent dea6975acc
commit 1ebf2bf884

View File

@@ -76,6 +76,29 @@ static inline int led_open()
}
#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)
{
int fd = dev_open();
@@ -164,6 +187,7 @@ void CLCD::showServicename(std::string name, bool)
servicename = name;
if (mode != MODE_TVRADIO)
return;
replace_umlauts(servicename);
strncpy(display_text, servicename.c_str(), sizeof(display_text) - 1);
display_text[sizeof(display_text) - 1] = '\0';
upd_display = true;
@@ -330,7 +354,9 @@ void CLCD::showMenuText(const int, const char *text, const int, const bool)
{
if (mode != MODE_MENU_UTF8)
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';
upd_display = true;
}