Translate with CCSID

xLateCCSID and xLateCCSIDEx

The ToEBCDIC procedure converts characters from one code page to the default EBCDIC code page for the system. The default source code page used is the ASCII 819 CCSID. This allows ASCII to EBCDIC conversion, however the source (input string's) CCSID may be another EBCDIC CCSID thus allowing conversion between different natural language character sets.

 bSuccess xLateCCSID(
  szInputString     65535A   Const Varying 
  szOutputString    65535A   OPTION(*VARSIZE)
  nLength              10I 0 Const OPTIONS(*NOPASS:*OMIT)
nFromCCSID 10I 0 Const OPTIONS(*NOPASS:*OMIT)
nToCCSID 10I 0 Const OPTIONS(*NOPASS:*OMIT)
bKeepOpen 10I 0 Const OPTIONS(*NOPASS:*OMIT)
)

See also: ToEBCDIC, ToHex

Parameters

szInputString
[input VChar(*) const]  A varying or fixed-length character value whose length is 1 to 65535. The value of this parameter is not modified but is translated from the CCSID specified on the nFromCCSID parameter to the CCSID specified on the nToCCSID parameter.
szOutputString
[input Char(*) ]  A fixed-length character variable whose length is 1 to 65535. This parameter receives the converted input string in the CCSID specified on nToCCSID parameter.
 
nLength [ optional ]
[input Int(4) const]  The length, in bytes, of the input string that is going to be translated. If this parameter is not specified, the length of the input string specified on the szInputString parameter is used. Use this parameter when the length of the output string is shorter than that of the input string. Specify *OMIT for this parameter when you want to force the subprocedure to use the length of the szInputString.
nFromCCSID  [optional] DFT(0)
[input in(4) const]  This parameter identifies the CCSID of the szInputString parameter's data. The text specified for szInputString must be in the CCSID specified for this parameter. If the parameter is not specified, the default CCSID for the job is used. Specifying zero (0) also implies the job's default CCSID.
 
nToCCSID  [optional] DFT(0)
[input in(4) const]  This parameter identifies the CCSID of the szOutputString parameter's data. The text specified for szOutputString must be in the CCSID specified for this parameter. If the parameter is not specified, the default CCSID for the job is used. Specifying zero (0) also implies the job's default CCSID.
bKeepOpen [ optional ] DFT(*OFF)
[input Indy const]  Specify *ON if you want to keep the conversion routine active for subsequent calls using the same From and To CCSIDs. This can greatly improve performance when repeatedly calling xLateCCSID. When finished, call xLateCCSID with bKeepOpen set to *OFF to close the conversion routine.  If no conversion is needed on that final call, specify a length of zero bytes for the nLength parameters.

Return Value

If the function succeeds, the return value is the szInputString parameter's data converted to the CCSID character set. If the function fails, no value is returned, that is the return value is an empty string, or blanks.

Remarks

This procedure uses the OS/400 iconv() API to do the conversion using CCSID codes.