From 4f7218fe62998c843bf80cca826aed79c215acac Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 15 Dec 2020 15:29:33 +0100 Subject: Do charset conversion for short label --- src/ensembledatabase.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3