MCPcopy Create free account
hub / github.com/antvis/F2Native / jniStringFromUTF8

Function jniStringFromUTF8

core/android/JNIUtil.cpp:438–447  ·  view source on GitHub ↗

替代StringToJavaString函数,解决jni里string乱码的问题

Source from the content-addressed store, hash-verified

436
437// 替代StringToJavaString函数,解决jni里string乱码的问题
438jstring jniStringFromUTF8(JNIEnv * env, const std::string & str) {
439 std::u16string utf16;
440 utf16.reserve(str.length()); // likely overallocate
441 for (std::string::size_type i = 0; i < str.length(); )
442 utf16_encode(utf8_decode(str, i), utf16);
443
444 jstring res = env->NewString(
445 reinterpret_cast<const jchar *>(utf16.data()), jsize(utf16.length()));
446 return res;
447}
448
449/*
450std::string GetJavaExceptionInfo(JNIEnv *env, jthrowable java_throwable)

Callers

nothing calls this directly

Calls 2

utf16_encodeFunction · 0.85
utf8_decodeFunction · 0.85

Tested by

no test coverage detected