String Parameters

Next, we want to consider how to transfer strings to and from native methods. As you know, strings in the Java programming language are sequences of UTF-16 code points whereas C strings are null-terminated sequences of bytes, so strings are quite different in the two languages. The Java Native Interface has two sets of functions for manipulating strings, one that converts Java strings to “modified UTF-8” byte sequences and one that converts them to arrays of UTF-16 values, that is, to jchar arrays. (The UTF-8, “modified UTF-8”, and UTF-16 formats were discussed in Volume 1, Chapter 12. Recall that the “modified UTF-8” encoding leaves ASCII characters unchanged, but all other Unicode characters are encoded as multibyte sequences.) ...

Get Core Java™ 2 Volume II - Advanced Features, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.