Convert to EBCDIC

ToEBCDIC

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 any CCSID thus allowing conversion between different character sets.

varying-char-value ToEBCDIC (
  szInputString    65535A   Const Varying 
  nCCSID              10I 0 Const Options(*NOPASS) 
)

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 to the default EBCDIC CCSID for the system running the procedure.
nCCSID  [optional]  (Source CCSID)
[input in(4) const]  This parameter identifies the CCSID of the source value. That is, the data specified on the szInputString parameter must be in this CCSID. If this parameter is not specified, the default CCSID of the job is used. Normally, this parameter is specified.

Return Value

If the function succeeds, the return value is the szInputString parameter's data converted to the default CCSID of the job. 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.