MCPcopy Create free account
hub / github.com/axmolengine/axmol / getStringUTFCharsJNI

Function getStringUTFCharsJNI

core/base/UTF8.cpp:349–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347
348#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID)
349std::string getStringUTFCharsJNI(JNIEnv* env, jstring srcjStr, bool* ret)
350{
351 std::string utf8Str;
352 if (srcjStr != nullptr && env != nullptr)
353 {
354 const unsigned short* unicodeChar = (const unsigned short*)env->GetStringChars(srcjStr, nullptr);
355 size_t unicodeCharLength = env->GetStringLength(srcjStr);
356 const std::u16string unicodeStr((const char16_t*)unicodeChar, unicodeCharLength);
357 bool flag = UTF16ToUTF8(unicodeStr, utf8Str);
358 if (ret)
359 {
360 *ret = flag;
361 }
362 if (!flag)
363 {
364 utf8Str = "";
365 }
366 env->ReleaseStringChars(srcjStr, unicodeChar);
367 }
368 else
369 {
370 if (ret)
371 {
372 *ret = false;
373 }
374 utf8Str = "";
375 }
376 return utf8Str;
377}
378
379jstring newStringUTFJNI(JNIEnv* env, std::string_view utf8Str, bool* ret)
380{

Calls 1

UTF16ToUTF8Function · 0.85

Tested by

no test coverage detected