aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-12-15 15:29:33 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-12-15 15:29:33 +0100
commit4f7218fe62998c843bf80cca826aed79c215acac (patch)
tree4b6d5e6db4dd06e05d27fa2c8eed8eaf07299263 /src
parentf469a8dabb304c7efa1e4c367082c7de2f2f0fdf (diff)
downloadetisnoop-4f7218fe62998c843bf80cca826aed79c215acac.tar.gz
etisnoop-4f7218fe62998c843bf80cca826aed79c215acac.tar.bz2
etisnoop-4f7218fe62998c843bf80cca826aed79c215acac.zip
Do charset conversion for short label
Diffstat (limited to 'src')
-rw-r--r--src/ensembledatabase.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ensembledatabase.cpp b/src/ensembledatabase.cpp
index 550fdf0..db7154a 100644
--- a/src/ensembledatabase.cpp
+++ b/src/ensembledatabase.cpp
@@ -82,7 +82,22 @@ std::string label_t::shortlabel() const
}
}
- return shortlabel;
+ switch (charset) {
+ case charset_e::COMPLETE_EBU_LATIN:
+ return convert_ebu_to_utf8(shortlabel);
+ case charset_e::UTF8:
+ return shortlabel;
+ case charset_e::UCS2:
+ try {
+ return ucs2toutf8((const uint8_t*)shortlabel.data(), shortlabel.size());
+ }
+ catch (const range_error&) {
+ return "";
+ }
+ case charset_e::UNDEFINED:
+ throw logic_error("charset undefined");
+ }
+ throw logic_error("invalid charset " + to_string((int)charset));
}
string label_t::assemble() const