From 4b0fcd411b8723aea48755dedfeefe5c21952d70 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 12 Dec 2019 23:59:58 +0100 Subject: COMMON: Fix string length in U32String::encode() Our method expects length in bytes, not in characters, which is 4x for U32 --- common/str-enc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/str-enc.cpp b/common/str-enc.cpp index 3aba06d58f..7d887e8a65 100644 --- a/common/str-enc.cpp +++ b/common/str-enc.cpp @@ -395,7 +395,7 @@ String U32String::encode(CodePage page) const { page >= ARRAYSIZE(g_codePageMap)) { error("Invalid codepage"); } - char *result = Encoding::convert(g_codePageMap[page], "UTF-32", (const char *)_str, _size); + char *result = Encoding::convert(g_codePageMap[page], "UTF-32", (const char *)_str, _size * 4); if (result) { // Encodings in CodePage all use '\0' as string ending // That would be problematic if CodePage has UTF-16 or UTF-32 -- cgit v1.2.3