summaryrefslogtreecommitdiff
path: root/core/utf8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/utf8.cpp')
-rw-r--r--core/utf8.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/utf8.cpp b/core/utf8.cpp
new file mode 100644
index 0000000..25ed595
--- /dev/null
+++ b/core/utf8.cpp
@@ -0,0 +1,25 @@
+#include "commonheaders.h"
+
+std::string toUTF8(std::wstring str)
+{
+ std::string ustr;
+ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ return ustr;
+}
+
+std::string toUTF8(std::string str)
+{
+ std::string ustr;
+ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ return ustr;
+}
+
+
+std::wstring toUTF16(std::string str) //convert as much as possible
+{
+ std::wstring ustr;
+ std::string tmpstr;
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
+ return ustr;
+}