convertEncodedTextToString()

The sysLib.convertEncodedTextToString() system function specifies an alternate encoding when you assign the value of a CHAR, MBCHAR, or DBCHAR variable to a UNICODE or STRING 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.convertEncodedTextToString(
    source CHAR | MBCHAR | DBCHAR in,
    encoding STRING in)
  returns (result STRING)
source
The name of a CHAR, MBCHAR, or DBCHAR 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.
result
A STRING or UNICODE variable where you want to store the converted text.

Example

The following example assigns text with ASCII Arabic encoding to a STRING variable:

aString = convertEncodedTextToString(aChar, "Cp1256");

Feedback