jstring(JNI) to std::string(c++) with utf8 characters

前端 未结 3 811
抹茶落季
抹茶落季 2021-02-02 11:11

How to convert jstring (JNI) to std::string (c++) with utf8 characters?

this is my code. it worked with non-utf8 characters, but i

3条回答
  •  感动是毒
    2021-02-02 11:50

    jboolean isCopy;
    const char *convertedValue = (env)->GetStringUTFChars(yourJStringParam, &isCopy);
    std::string string = std::string(convertedValue, length)
    

    This works just fine. Give it a try.

提交回复
热议问题