diff --git a/cocos/2d/ccUTF8.cpp b/cocos/2d/ccUTF8.cpp index 3d6714dab1..9e7e8ccc4d 100644 --- a/cocos/2d/ccUTF8.cpp +++ b/cocos/2d/ccUTF8.cpp @@ -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(outUtf16.length()); + } } return ret;