MCPcopy Create free account
hub / github.com/cocos/cocos-engine / newStringUTFJNI

Function newStringUTFJNI

native/cocos/base/UTF8.cpp:286–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286jstring newStringUTFJNI(JNIEnv *env, const ccstd::string &utf8Str, bool *ret) {
287 std::u16string utf16Str;
288 bool flag = cc::StringUtils::UTF8ToUTF16(utf8Str, utf16Str);
289
290 if (ret) {
291 *ret = flag;
292 }
293
294 if (!flag) {
295 utf16Str.clear();
296 }
297 jstring stringText = env->NewString(reinterpret_cast<const jchar *>(utf16Str.data()), utf16Str.length());
298 return stringText;
299}
300#endif
301
302ccstd::vector<char16_t> getChar16VectorFromUTF16String(const std::u16string &utf16) {

Callers 1

convertMethod · 0.85

Calls 4

UTF8ToUTF16Function · 0.85
clearMethod · 0.65
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected