summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/utf8.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/utf8.cpp b/core/utf8.cpp
index 7425af0..7b091a8 100644
--- a/core/utf8.cpp
+++ b/core/utf8.cpp
@@ -20,7 +20,9 @@
std::string toUTF8(std::wstring str)
{
std::string ustr;
- utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ std::wstring tmpstr;
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf16to8(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
return ustr;
}