summaryrefslogtreecommitdiffstats
path: root/lib/charset/charset.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-09 11:43:10 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-09 11:43:10 +0100
commit6902285dbc1c816f9c16d1d63a151b2022c094dc (patch)
tree4ea42146ffbcb54ad27526f4659099f77d435610 /lib/charset/charset.cpp
parentf4ef1284d754ecd907dd4ed3072f8be65b26f2de (diff)
downloaddabmux-6902285dbc1c816f9c16d1d63a151b2022c094dc.tar.gz
dabmux-6902285dbc1c816f9c16d1d63a151b2022c094dc.tar.bz2
dabmux-6902285dbc1c816f9c16d1d63a151b2022c094dc.zip
Convert labels from utf-8 to EBU
Diffstat (limited to 'lib/charset/charset.cpp')
-rw-r--r--lib/charset/charset.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/charset/charset.cpp b/lib/charset/charset.cpp
index 2ee14f8..5cc773d 100644
--- a/lib/charset/charset.cpp
+++ b/lib/charset/charset.cpp
@@ -52,3 +52,23 @@ const char* utf8_encoded_EBU_Latin[CHARSET_TABLE_ENTRIES] = {
"Â", "Ä", "Ê", "Ë", "Î", "Ï", "Ô", "Ö", "Û", "Ü", "ř", "č", "š", "ž", "đ", "ŀ",
"Ã", "Å", "Æ", "Œ", "ŷ", "Ý", "Õ", "Ø", "Þ", "Ŋ", "Ŕ", "Ć", "Ś", "Ź", "Ť", "ð",
"ã", "å", "æ", "œ", "ŵ", "ý", "õ", "ø", "þ", "ŋ", "ŕ", "ć", "ś", "ź", "ť", "ħ"};
+
+std::string CharsetConverter::convert_ebu_to_utf8(const std::string& str)
+{
+ using namespace std;
+
+ string utf8_str;
+ for (const uint8_t c : str) {
+ // Table offset because NUL is not represented
+ if (c >= CHARSET_TABLE_OFFSET) {
+ string utf8_char(utf8_encoded_EBU_Latin[c - CHARSET_TABLE_OFFSET]);
+ utf8_str += utf8_char;
+ }
+ else {
+ utf8_str += "⁇";
+ }
+ }
+
+ return utf8_str;
+}
+