Example: get and convert a code-page ID
The following example shows how you can use the callable services _iwzGetLocaleCP and _iwzGetCCSID to retrieve the locale and EBCDIC code page that are in effect, respectively, and convert a code-page ID to the corresponding CCSID.
cbl pgmname(lm)
Identification Division.
Program-ID. "Samp1".
Data Division.
Working-Storage Section.
01 locale-in-effect.
05 ll-cc pic x(5).
05 filler-period pic x.
05 ASCII-CP Pic x(14).
01 EBCDIC-CP pic x(10).
01 CCSID pic s9(5) comp-5.
01 RC pic s9(5) comp-5.
01 n pic 99.
Procedure Division.
Get-locale-and-codepages section.
Get-locale.
Display "Start Samp1."
Call "_iwzGetLocaleCP"
using locale-in-effect, EBCDIC-CP
Move 0 to n
Inspect locale-in-effect
tallying n for characters before initial x'00'
Display "locale in effect: " locale-in-effect (1 : n)
Move 0 to n
Inspect EBCDIC-CP
tallying n for characters before initial x'00'
Display "EBCDIC code page in effect: "
EBCDIC-CP (1 : n).
Get-CCSID-for-EBCDIC-CP.
Call "_iwzGetCCSID" using EBCDIC-CP, CCSID returning RC
Evaluate RC
When 0
Display "CCSID for " EBCDIC-CP (1 : n) " is " CCSID
When 1
Display EBCDIC-CP (1 : n)
" does not have a CCSID value."
When other
Display EBCDIC-CP (1 : n) " is not a valid code page."
End-Evaluate.
Done.
Goback.
If you set the locale to ja_JP.IBM-943 (set LC_ALL=ja_JP.IBM-943), the output from the sample program is:
Start Samp1.
locale in effect: ja_JP.IBM-943
EBCDIC code page in effect: IBM-1399
CCSID for IBM-1399 is 0000001399