Characters include letters, numbers, special characters, and other attributes. There are 3 groups of character data type: (1) alpha with letters: A-Z, a-z, and space, (2) numeric characters: 0-9, and (3) any characters. Characters are organized in code pages. Each code page combines a set of characters with a special designation, for example, it can be a region-specific code page. Each character in a code page has a numeric position.
The summary of character data type can be found in COBOL Data Types article.
Storage Description
The character data type represents characters converted from a source code page to the output one. Source code pages are a set of character tables supported by COBOL, for example, ibm037 coding is the most widespread one.
Sample 1
ibm037 code page
The code page is 1 byte. It contains 255 characters.
Converted to uft-8 bytes | H | e | l | l | o | e | v | e | r | y | b | o | d | y | ! | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hex ibm037 bytes | c8 | 85 | 93 | 93 | 96 | 40 | 85 | a5 | 85 | 99 | a8 | 82 | 96 | 84 | a8 | 5a |
Sample 2
ibm935 (Chinese) code page
The code page is 2 bytes. It contains 65535 characters.
English characters
Converted to uft-8 bytes | H | e | l | l | o | e | v | e | r | y | b | o | d | y | ! | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
hex ibm935 bytes | c8 | 85 | 93 | 93 | 96 | 40 | 85 | a5 | 85 | 99 | a8 | 82 | 96 | 84 | a8 | 5a |
Hello everybody! in Chinese
Converted to uft-8 bytes | Special byte to mark the beginning of a sequence of multi-byte codes | 大 | 家 | 好 | Special byte to mark the end of a sequence of multi-byte codes | ! |
---|---|---|---|---|---|---|
hex ibm935 bytes | 0e | 4af2 | 4ed1 | 4dc2 | 0f | 5a |
COBOL Representation Samples
Alpha Characters
01 VAR-CHARACTER PIC A(5).
01 VAR-CHARACTER PIC A(05).
01 VAR-CHARACTER PIC AAAAA.
Numeric Characters
01 VAR-CHARACTER PIC 9(5).
01 VAR-CHARACTER PIC 9(05).
01 VAR-CHARACTER PIC 99999.
Any Characters
01 VAR-CHARACTER PIC X(5).
01 VAR-CHARACTER PIC X(05).
01 VAR-CHARACTER PIC XXXXX.
Resources
- ebcdic-parser tool for converting of mainframe EBCDIC data into Unicode ASCII delimited text
Comments
comments powered by Disqus