issue #4660: Oops, utf16 is 2 bytes.

This commit is contained in:
James Chen 2014-05-08 17:21:19 +08:00
parent a61b1097db
commit b003ba5eb0
1 changed files with 5 additions and 1 deletions

View File

@ -256,7 +256,11 @@ unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1*/, int*
{
ret = new unsigned short[outUtf16.length() + 1];
ret[outUtf16.length()] = 0;
memcpy(ret, outUtf16.data(), outUtf16.length());
memcpy(ret, outUtf16.data(), outUtf16.length() * sizeof(unsigned short));
if (rUtf16Size)
{
*rUtf16Size = static_cast<int>(outUtf16.length());
}
}
return ret;