convertStringToEncodedText()

The sysLib.convertStringToEncodedText() system function specifies an alternate encoding when you assign the value of a UNICODE or STRING variable to a CHAR, MBCHAR, or DBCHAR variable.

EGL assumes that CHAR, MBCHAR, or DBCHAR variables always use the default file encoding for Java™ programs or the default encoding specified for COBOL compilation. Use the sysLib.convertEncodedTextToString() and sysLib.convertStringToEncodedText() system functions to specify the encoding of character text (CHAR, MBCHAR, or DBCHAR variables) when those variables are converted to UNICODE text in a UNICODE or STRING variable and vice versa. This allows different encodings to be used within a single program.

Syntax

  sysLib.convertStringToEncodedText(
    source STRING in,
    encoding STRING in,
    target CHAR | MBCHAR | DBCHAR inout)
source
The name of a STRING or UNICODE variable whose contents are to be converted.
encoding
One of the following STRING values:
  • For COBOL environments, the value must have the form "Cp" followed by the IBM® CCSID for the code page.
  • For Java environments, the value is any valid encoding accepted by the java.lang.String.getBytes() method.
target
A CHAR, MBCHAR, or DBCHAR variable where you want to store the converted string.

Example

The following example assigns the value of the UNICODE text in a STRING variable to a CHAR variable using ASCII Arabic encoding:

convertStringToEncodedText(aString, "Cp1256", aChar);

Feedback