From 3c5d25cc63a15efe6fe8ff80d6c6522ed546872c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 26 Sep 2016 18:35:56 +0200 Subject: [PATCH] lcd4l: try to fix encoding mess Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/bdbd8b55922e438ee0c82a5b5dc76751665746a2 Author: vanhofen Date: 2016-09-26 (Mon, 26 Sep 2016) Origin message was: ------------------ - lcd4l: try to fix encoding mess ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/lcd4l.cpp | 28 ++++++++++++---------------- src/gui/lcd4l.h | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/gui/lcd4l.cpp b/src/gui/lcd4l.cpp index 44cfa1a1f..81cb04a77 100644 --- a/src/gui/lcd4l.cpp +++ b/src/gui/lcd4l.cpp @@ -792,13 +792,13 @@ bool CLCD4l::WriteFile(const char *file, std::string content, bool convert) if (convert) // align to internal lcd4linux font { - strReplace(content, "ä", "á"); - strReplace(content, "ö", "ï"); - strReplace(content, "ü", "õ"); - strReplace(content, "Ä", "Ae"); - strReplace(content, "Ö", "Oe"); - strReplace(content, "Ü", "Ue"); - strReplace(content, "ß", "â"); + strReplace(content, "ä", "\xe1\0"); + strReplace(content, "ö", "\xef\0"); + strReplace(content, "ü", "\xf5\0"); + strReplace(content, "Ä", "\xc4\0"); + strReplace(content, "Ö", "\xd6\0"); + strReplace(content, "Ü", "\xdc\0"); + strReplace(content, "ß", "\xe2\0"); strReplace(content, "é", "e"); } @@ -853,17 +853,13 @@ bool CLCD4l::CompareParseID(uint64_t &i_ParseID) return ret; } -// stolen from gui/movieinfo.cpp -void CLCD4l::strReplace(std::string & orig, const char *fstr, const std::string rstr) +void CLCD4l::strReplace(std::string &orig, const std::string &fstr, const std::string &rstr) { - unsigned int index = 0; - unsigned int fstrlen = strlen(fstr); - int rstrlen = rstr.size(); - - while ((index = orig.find(fstr, index)) != std::string::npos) + size_t pos = 0; + while ((pos = orig.find(fstr, pos)) != std::string::npos) { - orig.replace(index, fstrlen, rstr); - index += rstrlen; + orig.replace(pos, fstr.length(), rstr); + pos += rstr.length(); } } diff --git a/src/gui/lcd4l.h b/src/gui/lcd4l.h index a172bad48..7506e1b1a 100644 --- a/src/gui/lcd4l.h +++ b/src/gui/lcd4l.h @@ -80,7 +80,7 @@ class CLCD4l bool GetLogoName(uint64_t channel_id, std::string channel_name, std::string & logo); std::string hexStr(unsigned char* data); - void strReplace(std::string & orig, const char *fstr, const std::string rstr); + void strReplace(std::string &orig, const std::string &fstr, const std::string &rstr); bool WriteFile(const char *file, std::string content = "", bool convert = false); // Variables