CODEPAGE-CONVERT function
Converts a string value from one code page to another.
Syntax
source-string
target-codepage
A character-string expression that evaluates to the name of a code page. The returned character value is relative totarget-codepage
. The name that you specify must be a valid code page name available in theDLC/convmap.cp
file (a binary file that contains all of the tables that ABL uses for character management). If you supply a non-valid name, the CODEPAGE-CONVERT function returns the Unknown value (?
). Before returning a character value, the CODEPAGE-CONVERT function convertssource-string
fromsource-codepage
totarget-codepage
. If you do not specifytarget-codepage
, no code page conversions occur.source-codepage
A character-string expression that evaluates to the name of a code page. Thesource-codepage
specifies the name of the code page to whichsource-string
is relative. The name that you specify must be a valid code page name available in theDLC/convmap.cp
file. If you supply a non-valid name, the CODEPAGE-CONVERT function returns the Unknown value (?
). The default value ofsource-codepage
is the value of CHARSET attribute of the SESSION handle.Ifsource-string
is a LONGCHAR variable, thesource-codepage
argument is not valid. In this case, the code page of the LONGCHAR variable is used as the source code page.ExampleThis example assumes that the native code page of
r-codpag.p
is ibm850. It is written so that its embedded text strings are always converted to the internal code page of the ABL session (SESSION:CHARSET).
Notes
- The CODEPAGE-CONVERT function returns the corresponding character string in the specified code page. By default, the value of SESSION:CHARSET is iso8859-1. You can set a different internal code page by specifying the Internal Code Page (-cpinternal) parameter. For more information, see OpenEdge Development: Internationalizing Applications and OpenEdge Deployment: Startup Command and Parameter Reference.
- This function is especially useful if you plan to run a procedure in an ABL session in which the SESSION:CHARSET code page is different from the native code page of the procedure.
- When you write procedures with ABL, you must use 7-bit (that is, ASCII) characters for field names and variable names. But you can use 8-bit and multi-byte characters, including Unicode, for data values such as character strings and constants. Thus, a procedure written and compiled on a system using one code page can be run on a system using another code page as long as you convert all embedded character strings to the internal code page. Using CODEPAGE-CONVERT as shown in the example allows your procedures to be virtually code page independent.
See also
OpenEdge Release 10.2B
|