JString (JNI) bis Std :: String (C ++) mit UTF8 -Zeichen

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: JString (JNI) bis Std :: String (C ++) mit UTF8 -Zeichen

by Anonymous » 11 Jul 2025, 14:10

Wie konvertieren Sie JString (jni) in std :: string (c ++) mit utf8 Zeichen?

Dies ist mein Code. Es hat mit Nicht-UTF8-Zeichen funktioniert, aber es ist falsch mit UTF8-Zeichen. < /p>

Code: Select all

std::string jstring2string(JNIEnv *env, jstring jStr){
const char *cstr = env->GetStringUTFChars(jStr, NULL);
std::string str = std::string(cstr);
env->ReleaseStringUTFChars(jStr, str);
return str;
}

Top