Computer systems store text data using character codes, typically 7 or 8–bit numeric codes that map to specific visual character representations. The series of character codes that make up the character set that a system uses is referred to as a code page.
ABL provides a character set management facility to automatically convert data between the code pages of different data sources and destinations (targets). In general, the supported data sources and targets for code page conversion include memory, streams, and databases. You can specify default code page conversions for a session using conversion tables and startup parameters to specify the code page for each data source and target. For more information on this character set facility, see OpenEdge Development: Internationalizing Applications.
ABL also allows you to perform I/O that explicitly converts data from one code page to another in order to facilitate I/O between data sources and destinations intended for different computer systems or components. You can specify the name of the code page for a data source and target as parameters to several statements and functions.
To convert between source and target characters or strings in memory, you can specify code page parameters in these functions:
ASC
CHR
CODEPAGE–CONVERT
To convert data input and output, you can specify code page parameters in these statements:
INPUTFROM (input source to memory target)
OUTPUTTO (memory source to output target)
To convert piped input and output, you can specify code page parameters in these statements:
INPUTTHROUGH (program source to memory target)
OUTPUTTHROUGH (memory source to program target)
INPUT–OUTPUT THROUGH (program source to program target)
These statements and functions take available code page name parameters as character expressions (for example, "ibm850"). The code page names you specify must be defined in your ABL conversion map file (convmap.cp, by default). Also, the source and target conversion tables must be defined in the conversion map file for each code page to support the specified conversions. For more information on building a conversion map file, see OpenEdge Development: Internationalizing Applications.
For example, the i-codpag.p procedure writes to two output streams using two different code pages.
i-codpag.p
DEFINE VARIABLE xname NO-UNDO LIKE Customer.Name INITIAL ?.
DO WHILE xname <> "":
ASSIGN xname = "".
DISPLAY xname LABEL "Starting Name to German List"
WITH FRAME a SIDE-LABELS.
SET xname WITH FRAME a.
IF xname <> "" THEN DO:
OUTPUT TO german.txt
CONVERT SOURCE "iso8859-1" TARGET "german-7-bit".
FOR EACH Customer NO-LOCK WHERE Customer.Name >= xname
BY Customer.Name:
DISPLAY Customer WITH STREAM-IO.
END.
OUTPUT CLOSE.
OUTPUT TO swedish.txt
CONVERT SOURCE "iso8859-1" TARGET "swedish-7-bit".
FOR EACH Customer WHERE Customer.Name < xname BY Customer.Name:
DISPLAY Customer WITH STREAM-IO.
END.
OUTPUT CLOSE.
END.
END.
For this example, assume that the internal code page is "iso8859–1". If a customer name from the sports2000 database is greater than or equal to a prompted name (xname), then the procedure writes the corresponding Customer record to the file, german.txt, using the "german–7–bit" code page. Otherwise, it writes the corresponding Customer record to the file, swedish.txt, using the "swedish–7–bit" code page. These conversions are handled by the conversion tables provided with ABL.
For more information on specifying code page parameters, see the reference entry for each statement or function that supports code page conversion in OpenEdge Development: ABL Reference.