Performing code-page conversions
- Last Updated: October 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Performing code-page conversions
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 Internationalize ABL 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 Internationalize ABL Applications.
For example, the i-codpag.p procedure writes to two output streams using two different code pages.
i-codpag.p
|
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 ABL Reference.