Consultor Eletrônico



Kbase P122434: CODEPAGE-CONVERT fails to convert Longchar to UTF-8
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2009
Status: Unverified

SYMPTOM(s):

CODEPAGE-CONVERT fails to convert Longchar to UTF-8

Converting single byte extended characters to UTF-8 multi byte characters fails with the CODEPAGE-CONVERT function if the function is executed on a LONGCHAR variable.

CODEPAGE-CONVERT works correctly with CHARACTER data types. this is only a problem with LONGCHAR.

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.x

CAUSE:

This is functioning as designed.

In this case the LONGCHAR does not have a codepage, so the initial assignment sets a codepage of -cpinternal(1252). CODEPAGE-CONVERT converts the data in the LONGCHAR to UTF-8 then sets the LONGCHARs codepage to UTF-8.

Then, when we execute STRING(<longchar>), we convert the data from the LONGCHAR's codepage to -cpinternal. The number of bytes used to store the characters changes depending upon the codepage used to manipulate the data and the internal codepage (1252) sees fewer bytes and cannot convert the characters.

When changing the datatype of the LONGCHAR to CHARACTER you are removing all the automatic codepage conversions and thus attempts to convert to the internal codepage.


FIX:

Ensure that the internal codepage either matches that of the LONGCHAR variable or that the string is convertible between those codepages.