To avoid problems with the different data representation between ASCII and EBCDIC characters, use the CHAR(EBCDIC) compiler option.
The Windows-based workstation uses the ASCII character set, and the mainframe uses the EBCDIC character set. Therefore, most characters have a different hexadecimal value, as shown in the following table.
| Character | Hexadecimal value if ASCII | Hexadecimal value if EBCDIC |
|---|---|---|
| '0' through '9' | X'30' through X'39' | X'F0' through X'F9' |
| 'a' | X'61' | X'81' |
| 'A' | X'41' | X'C1' |
| blank | X'20' | X'40' |
Also, code that depends on the EBCDIC hexadecimal values of character data probably fails when the character data has ASCII values, as shown in the following table.
| Comparison | Evaluation if ASCII | Evaluation if EBCDIC |
|---|---|---|
| 'a' < 'A' | False | True |
| 'A' < '1' | False | True |
| x >= '0' | If true, does not indicate whether x is a digit | If true, x is probably a digit |
| x = X'40' | Does not test whether x is a blank | Tests whether x is a blank |
Because of these differences, the results of sorting character strings are different between EBCDIC and ASCII. For many programs, these differences have no effect, but you should be aware of potential logic errors if your program depends on the exact sequence in which some character strings are sorted. If your program depends on the EBCDIC collating sequence and you are porting it to the workstation, you can obtain the EBCDIC collating sequence by using PROGRAM COLLATING SEQUENCE IS EBCDIC or the COLLSEQ(EBCDIC) compiler option.