COBOL represents Java String data in Unicode. To represent a Java String in a COBOL program, declare the string as an object reference of the jstring class. Then use JNI services to set or extract COBOL national (Unicode) or UTF-8 data from the object.
Services for Unicode: Use the following standard services to convert between jstring object references and COBOL USAGE NATIONAL data items. Use these services for applications that you intend to be portable between the workstation and the mainframe. Access these services by using function pointers in the JNINativeInterface environment structure.
| Service | Input arguments | Return value |
|---|---|---|
| NewString1 |
|
jstring object reference |
| GetStringLength |
|
The number of Unicode characters in the jstring object reference; binary fullword |
| GetStringChars1 |
|
|
| ReleaseStringChars |
|
None; the storage for the array is released. |
|
||
Services for UTF-8: You can use the following services, an extension of the JNI, to convert between jstring object references and UTF-8 strings. Use these services in programs that do not need to be portable to the mainframe. Access these services by using function pointers in the JNI environment structure JNINativeInterface.
| Service | Input arguments | Return value |
|---|---|---|
| NewStringUTF1 |
|
jstring object reference, or NULL if the string cannot be constructed |
| GetStringUTFLength |
|
The number of bytes needed to represent the string in UTF-8 format; binary fullword |
| GetStringUTFChars1 |
|
|
| ReleaseStringUTFChars |
|
None; the storage for the UTF-8 string is released. |
|
||
related tasks
Accessing JNI services
Coding interoperable data types in COBOL and Java
Declaring arrays and strings for Java
Using national data (Unicode) in COBOL
Compiling, linking, and running OO applications