NewStringUTF conversion of euro character

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€
 
R

Roedy Green

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.

Is there a method to tell you what the native C encoding is? You can
then play with translations in pure Java to see if there is a bug in
the translate table. The Euro was only recently added.

See http://mindprod.com/jgloss/encoding.html

Check out the control panel in windows. Perhaps you have an old
encoding configured as the default or out of date translate tables.

See also Wassup to find out the default encoding in Java.

http://mindprod.com/wassup.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top