Convert to ASCII

ToASCII

The ToASCII procedure converts characters in the EBCDIC (using the system's default CCSID) to ASCII (using CCSID 819).

varying-char-value ToASCII(
  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 ASCII CCSID specified on the nCCSID parameter. The text in this parameter is assumed to be in the current CCSID of the job.
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.

Return Value

If the function succeeds, the return value is the converted text from the szInputString parameter. The converted text will being in the nCCSID character set (e.g., U.S. ASCII 819). 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.