| Modifier and Type | Field and Description |
|---|---|
| public static final byte[] | |
| public static final char[] | |
| public static final byte[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static String | Returns: String based on the most popraw bits from the OS. bytes)Given a byte array with unknown encoding, try to decode it via (relatively simple) heuristic. |
| public static String | Returns: a Java String object.- A char * or a gchar *. Which will be freed up afterwards. cCharPtr, boolean - "true" means free up memory pointed to by cCharPtr.
CAREFUL! If this string is part of a struct (ex GError), and a specialized
free function (like g_error_free(..) is called on the whole struct, then you
should not free up individual struct members with this function,
as otherwise you can get unpredictable behavior). freecCharPtr)This method takes a 'C' pointer (char *) or (gchar *), reads characters up to the terminating symbol '\0' and converts it into a Java String. |
| public static byte[] | Returns: a pointer to a C String. In C, this would be a 'char *'A java string. string)Given a java String, convert it to a regular null terimnated C string, to be used when calling a native C function. |
| public static char[] | Returns: char array representing the string. Usually used for String construction like: new String(mbcsToWcs(..))- byte buffer with C bytes representing a string. buffer)Convert a "C" multibyte UTF-8 string byte array into a Java UTF-16 Wide character array. |
| public static char | Returns: Java UTF-16 Wide character- C Multibyte UTF-8 character ch)Convert C UTF-8 Multibyte character into a Java UTF-16 Wide character. |
| public static byte[] | |
| public static byte[] | Returns: byte array that can be passed to a native function.- a regular Java String chars, boolean - if terminate)true the byte buffer should be terminated with a null character.Convert a Java UTF-16 Wide character array into a C UTF-8 Multibyte byte array. |
| public static char | Returns: C UTF-8 Multibyte character.- Java UTF-16 wide character. ch)Convert a Java UTF-16 Wide character into a single C UTF-8 Multibyte character that you can pass to a native function. |
| EmptyByteArray | back to summary |
|---|---|
| public static final byte[] EmptyByteArray | |
| EmptyCharArray | back to summary |
|---|---|
| public static final char[] EmptyCharArray | |
| NullByteArray | back to summary |
|---|---|
| public static final byte[] NullByteArray | |
| Converter | back to summary |
|---|---|
| public Converter() | |
| byteToStringViaHeuristic | back to summary |
|---|---|
| public static String byteToStringViaHeuristic(byte[] bytes) Given a byte array with unknown encoding, try to decode it via (relatively simple) heuristic.
This is useful when we're not provided the encoding by OS/library.
| |
| cCharPtrToJavaString | back to summary |
|---|---|
| public static String cCharPtrToJavaString(long cCharPtr, boolean freecCharPtr) This method takes a 'C' pointer (char *) or (gchar *), reads characters up to the terminating symbol '\0' and converts it into a Java String. Note In SWT we don't use JNI's native String functions because of the 3 vs 4 byte issue explained in Class description. Instead we pass a character pointer from C to java and convert it to a String in Java manually.
| |
| javaStringToCString | back to summary |
|---|---|
| public static byte[] javaStringToCString(String string) Given a java String, convert it to a regular null terimnated C string, to be used when calling a native C function.
| |
| mbcsToWcs | back to summary |
|---|---|
| public static char[] mbcsToWcs(byte[] buffer) Convert a "C" multibyte UTF-8 string byte array into a Java UTF-16 Wide character array.
| |
| mbcsToWcs | back to summary |
|---|---|
| public static char mbcsToWcs(char ch) Convert C UTF-8 Multibyte character into a Java UTF-16 Wide character.
| |
| wcsToMbcs | back to summary |
|---|---|
| public static byte[] wcsToMbcs(String string, boolean terminate) Convert a Java UTF-16 Wide character string into a C UTF-8 Multibyte byte array. This algorithm stops when it finds the first NULL character. I.e, if your Java String has embedded NULL characters, then the returned string will only go up to the first NULL character.
| |
| wcsToMbcs | back to summary |
|---|---|
| public static byte[] wcsToMbcs(char[] chars, boolean terminate) Convert a Java UTF-16 Wide character array into a C UTF-8 Multibyte byte array. This algorithm stops when it finds the first NULL character. I.e, if your Java String has embedded NULL characters, then the returned string will only go up to the first NULL character.
| |
| wcsToMbcs | back to summary |
|---|---|
| public static char wcsToMbcs(char ch) Convert a Java UTF-16 Wide character into a single C UTF-8 Multibyte character that you can pass to a native function.
| |