summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/charset/charset.h14
1 files changed, 11 insertions, 3 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;