Skip to content

Instantly share code, notes, and snippets.

@0xF6
Created November 9, 2015 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xF6/7f7b705f5b4f18727542 to your computer and use it in GitHub Desktop.
Save 0xF6/7f7b705f5b4f18727542 to your computer and use it in GitHub Desktop.
CLR String to JNI String
jstring Aix::tojString(JNIEnv * pEnv, String^ str)
{
array<byte>^ arr = Encoding::UTF8->GetBytes(str);
pin_ptr<Byte> pinnedBytes = &arr[0];
jstring s = pEnv->NewStringUTF(reinterpret_cast<char*>(pinnedBytes));
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment