Forum Stats

  • 3,837,113 Users
  • 2,262,228 Discussions
  • 7,900,208 Comments

Discussions

French character accent garbled

852802
852802 Member Posts: 3
edited Apr 5, 2011 12:28PM in Java Native Interface (JNI)
Hi


I'm using JNI to retrieve a string from C++ code to Java.
The problem is that the string contains some extended-ASCII characters
specifically some French characters.

When the string is returned to Java an implicit conversion is performed to
convert the bytes into Unicode characters but the problem is that these
extended characters are not being mapped correctly.

Answers

  • 802316
    802316 Member Posts: 532
    You may have to set the character encoding correctly to match the encoding used in your String.
  • tschodt
    tschodt Member Posts: 537
    849799 wrote:
    I'm using JNI to retrieve a string from C++ code to Java.
    The problem is that the string contains some extended-ASCII characters
    specifically some French characters.

    When the string is returned to Java an implicit conversion is performed to
    convert the bytes into Unicode characters but the problem is that these
    extended characters are not being mapped correctly.
    A Java String is a sequence of characters encoding UNICODE characters as UTF-16.

    Typically a C++ "string" will be a byte array representing characters in some encoding.

    You can pass a byte array (and encoding) from C++ to Java and let Java create a String from the byte array.
This discussion has been closed.