Commit 135e897e authored by suzuki toshiya's avatar suzuki toshiya Committed by Adam Reichold

Improve handling of UTF-16 in cpp frontend by considering Endianess

parent a4fad73c
......@@ -226,7 +226,11 @@ byte_array ustring::to_utf8() const
return byte_array();
}
MiniIconv ic("UTF-8", "UTF-16");
#ifdef WORDS_BIGENDIAN
MiniIconv ic("UTF-8", "UTF-16BE");
#else
MiniIconv ic("UTF-8", "UTF-16LE");
#endif
if (!ic.is_valid()) {
return byte_array();
}
......@@ -274,7 +278,11 @@ ustring ustring::from_utf8(const char *str, int len)
}
}
MiniIconv ic("UTF-16", "UTF-8");
#ifdef WORDS_BIGENDIAN
MiniIconv ic("UTF-16BE", "UTF-8");
#else
MiniIconv ic("UTF-16LE", "UTF-8");
#endif
if (!ic.is_valid()) {
return ustring();
}
......
......@@ -93,7 +93,7 @@ ustring detail::unicode_GooString_to_ustring(const GooString *str)
ustring detail::unicode_to_ustring(const Unicode *u, int length)
{
ustring str(length * 2, 0);
ustring str(length, 0);
ustring::iterator it = str.begin();
const Unicode *uu = u;
for (int i = 0; i < length; ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment