H
Hicks
This is a JNI question related to C/Java. I'm using j2sdk1.4.2_03.
I have a string containing a euro character € and I'm using
NewStringUTF to convert it from a native char* into a jstring. However
when the jstring is passed from the C code into a Java method, the
euro character has been converted into a '?' character.
As a test, I tried calling GetStringUTFChars in the C code to see if
the string could be converted back to a char*, and the returned value
seems to have an extra character inserted before the euro symbol (see
output).
Does anyone have any experience with this, or can offer advice on
what's happening?
proEAI_Debug (EAIDBG_PROC, "EAI_JAVA: EAIRun_Call() - Tokenized field
info is: %s", results);
resultJString = (*javaEnv)->NewStringUTF(javaEnv, (const char *)
results);
utf_string = (*javaEnv)->GetStringUTFChars(javaEnv, resultJString,
&isCopy);
proEAI_Debug (EAIDBG_PROC, "EAI_JAVA: EAIRun_Call() - utf_string =
%s", utf_string);
---------------------------- Output ----------------------------------
040629171739.474712:x004: EAI_JAVA: EAIRun_Call() - Tokenized field
info is: NAME2F07TEXTMEMA200MAXLENDDDDDDDD2A200NAMETAX1MF08NAMETAX1A200AMEMOF01ATEXTA200test1€
040629171739.474893:x004: EAI_JAVA: EAIRun_Call() - utf_string =
NAME2F07TEXTMEMA200MAXLENDDDDDDDD2A200NAMETAX1MF08NAMETAX1A200AMEMOF01ATEXTA200test1€
I have a string containing a euro character € and I'm using
NewStringUTF to convert it from a native char* into a jstring. However
when the jstring is passed from the C code into a Java method, the
euro character has been converted into a '?' character.
As a test, I tried calling GetStringUTFChars in the C code to see if
the string could be converted back to a char*, and the returned value
seems to have an extra character inserted before the euro symbol (see
output).
Does anyone have any experience with this, or can offer advice on
what's happening?
proEAI_Debug (EAIDBG_PROC, "EAI_JAVA: EAIRun_Call() - Tokenized field
info is: %s", results);
resultJString = (*javaEnv)->NewStringUTF(javaEnv, (const char *)
results);
utf_string = (*javaEnv)->GetStringUTFChars(javaEnv, resultJString,
&isCopy);
proEAI_Debug (EAIDBG_PROC, "EAI_JAVA: EAIRun_Call() - utf_string =
%s", utf_string);
---------------------------- Output ----------------------------------
040629171739.474712:x004: EAI_JAVA: EAIRun_Call() - Tokenized field
info is: NAME2F07TEXTMEMA200MAXLENDDDDDDDD2A200NAMETAX1MF08NAMETAX1A200AMEMOF01ATEXTA200test1€
040629171739.474893:x004: EAI_JAVA: EAIRun_Call() - utf_string =
NAME2F07TEXTMEMA200MAXLENDDDDDDDD2A200NAMETAX1MF08NAMETAX1A200AMEMOF01ATEXTA200test1€