aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-10-09 03:29:40 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-10-09 03:29:40 +0000
commit4580c9fc0c1b1677472f822deca21b53ecba45a6 (patch)
tree60646f039565e4865a8265830b6693c9b8fe4390 /lib
parentac2585b1cf9b605723d9fe593c04f138086976a6 (diff)
downloadenigma2-4580c9fc0c1b1677472f822deca21b53ecba45a6.tar.gz
enigma2-4580c9fc0c1b1677472f822deca21b53ecba45a6.zip
add removeDVBChars, makeUpper string functions
Diffstat (limited to 'lib')
-rw-r--r--lib/base/estring.cpp35
-rw-r--r--lib/base/estring.h3
2 files changed, 37 insertions, 1 deletions
diff --git a/lib/base/estring.cpp b/lib/base/estring.cpp
index aee17429..72ca3654 100644
--- a/lib/base/estring.cpp
+++ b/lib/base/estring.cpp
@@ -23,7 +23,7 @@ std::string getNum(int val, int sys)
return res;
}
- // 8859-x to dvb coding tables. taken from www.unicode.org/Public/MAPPINGS/ISO8859/
+ // 8859-x to ucs coding tables. taken from www.unicode.org/Public/MAPPINGS/ISO8859/
static unsigned long c88595[128]={
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
@@ -375,3 +375,36 @@ int isUTF8(const std::string &string)
return 1; // can be UTF8 (or pure ASCII, at least no non-UTF-8 8bit characters)
}
+std::string removeDVBChars(const std::string &s)
+{
+ std::string res;
+
+ int len = s.length();
+
+ for(int i = 0; i < len-1; i++)
+ {
+ unsigned char c1 = s[i];
+ unsigned int c;
+
+ /* UTF8? decode (but only simple) */
+ if(c1 > 0x80)
+ {
+ unsigned char c2 = s[i + 1];
+ c = ((c1&0x3F)<<6) + (c2&0x3F);
+ if ((c >= 0x80) && (c <= 0x9F))
+ {
+ ++i; /* skip 2nd utf8 char */
+ continue;
+ }
+ }
+
+ res += s[i];
+ }
+
+ return res;
+}
+
+void makeUpper(std::string &s)
+{
+ std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper);
+}
diff --git a/lib/base/estring.h b/lib/base/estring.h
index a0b161de..1698ac22 100644
--- a/lib/base/estring.h
+++ b/lib/base/estring.h
@@ -15,4 +15,7 @@ std::string convertDVBUTF8(const std::string &s, int table=5);
std::string convertLatin1UTF8(const std::string &string);
int isUTF8(const std::string &string);
+std::string removeDVBChars(const std::string &s);
+void makeUpper(std::string &s);
+
#endif // __E_STRING__