summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/charset/charset.h14
-rw-r--r--src/MuxElements.cpp7
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/charset/charset.h b/lib/charset/charset.h
index 78dc94e..c6a3001 100644
--- a/lib/charset/charset.h
+++ b/lib/charset/charset.h
@@ -51,13 +51,21 @@ class CharsetConverter
}
}
- /*! Convert a UTF-8 encoded text line into an EBU Latin encoded byte stream
+ /*! Convert a UTF-8 encoded text line into an EBU Latin encoded byte
+ * stream. If up_to_first_error is set, convert as much text as possible.
+ * If false, raise an exception in case of conversion errors.
*/
- std::string convert(std::string line_utf8) {
+ std::string convert(std::string line_utf8, bool up_to_first_error = true) {
using namespace std;
// check for invalid utf-8, we only convert up to the first error
- string::iterator end_it = utf8::find_invalid(line_utf8.begin(), line_utf8.end());
+ string::iterator end_it;
+ if (up_to_first_error) {
+ end_it = utf8::find_invalid(line_utf8.begin(), line_utf8.end());
+ }
+ else {
+ end_it = line_utf8.end();
+ }
// Convert it to utf-32
vector<uint32_t> utf32line;
diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp
index a31791a..24c81b3 100644
--- a/src/MuxElements.cpp
+++ b/src/MuxElements.cpp
@@ -179,7 +179,7 @@ int DabLabel::setLabel(const std::string& label)
m_flag = 0xFF00; // truncate the label to the eight first characters
try {
- m_label = charset_converter.convert(label);
+ m_label = charset_converter.convert(label, false);
}
catch (const utf8::exception& e) {
etiLog.level(warn) << "Failed to convert label '" << label <<
@@ -196,9 +196,10 @@ int DabLabel::setLabel(const std::string& label, const std::string& short_label)
newlabel.m_flag = 0xFF00;
try {
- newlabel.m_label = charset_converter.convert(label);
+ newlabel.m_label = charset_converter.convert(label, false);
- int flag = newlabel.setShortLabel(charset_converter.convert(short_label));
+ int flag = newlabel.setShortLabel(
+ charset_converter.convert(short_label, false));
if (flag < 0) {
return flag;
}