Kbase P108864: How to enter Chinese characters into a UTF-8 database with 4GL.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/09/2005 |
|
Status: Unverified
GOAL:
How to enter Chinese characters into a UTF-8 database with 4GL.
GOAL:
How can Chinese characters be written to a unicode database.
FIX:
Use the CHR function to convert the UTF-8 value of the character to the code page being used by the client, before writing it to the database. For example, with a Progress session started with cpinternal and cpstream CP936, and connected to a UTF-8 database the following writes a Chinese ideograph to the customer name field:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE c1 AS CHARACTER NO-UNDO.
c1 = CHR(14989731, "CP936","UTF-8").
FOR EACH customer:
NAME = NAME + c1.
END.
FOR EACH customer:
DISPLAY NAME.
END.
The character being used here is the ideograph at Unicode position 4E63. This converts to a UTF-8 3 byte value of e4b9a3 whose integer conversion is 14989731. The character itself looks like a stacked column of diagonal lines on the left and a back to front (tail pointing to the right not the left) capital letter J on the right.
Therefore the code converts the unicode value to CP936 (the client code page) then tags this onto the end of the customer.name field. The value is then re-displayed on the client.