Consultor Eletrônico



Kbase P124989: How to convert characters between code pages using CHR() function
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/03/2009
Status: Unverified

GOAL:

How to convert characters between code pages using CHR(<char>) function

GOAL:

How to avoid problems with hard coded characters using CHR function.

GOAL:

How to avoid problems with CHR function and hard-coded characters.

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
OpenEdge Category: Language (4GL/ABL)

FIX:

Each code page has its own set of characters and their respective values. Most of the common characters in western languages share the same code in all code pages, but sometimes applications need to represent special characters, like currency symbols for instance. Progress 4GL provides 2 additional parameters in CHR() function, that allow programmers to specify source and target code pages.
Another approach is to have a property file or any other device to store an internal table of special symbols like line breaks, currency, or any other special chars hard coded in the 4GL code. This technique requires first reading the char code from the table before calling the CHR(), and is even better than just using source and target, because allows programmers to find define alternative characters, for cases where source and target are not 100% convertible among each other.