CODEPAGE-CONVERT to UTF-32

Posted by Valeriy Bashkatov on 10-Apr-2015 04:32

Hello,

OE: 10.2B & 11.5

I found problem with this.

This simple code demonstrate the problem:

DEFINE VARIABLE tst AS CHAR INITIAL "CONVERSION".
DEFINE VARIABLE tstutf8 AS CHAR.
DEFINE VARIABLE tstutf32 AS CHAR.

DISPLAY SESSION:CHARSET ": " tst FORMAT "x(76)" SKIP. PAUSE.


tstutf8 = CODEPAGE-CONVERT ( tst, "UTF-8" ). /*no problem*/

DISPLAY "UTF-8: " tstutf8 FORMAT "x(76)" SKIP. pause.


tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32").  /*problem here*/

DISPLAY "UTF-32: "tstutf32 FORMAT "x(76)" SKIP. pause.


In string with CODEPAGE-CONVERT (tstutf8, "UTF-32") I get 

SYSTEM ERROR: Memory violation. (49)
** Save file named core for analysis by Progress Software Corporation. (439)

OpenEdge has support UTF-32?

Posted by Aidan Jeffery on 10-Apr-2015 07:34

What is the -cpinternal of your session?
 
If it is not utf-8, then you need to specify it as the source code page in the conversion from utf-8 to utf-32:
 
tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32", “UTF-8”).
 
 
[collapse]
From: Valeriy Bashkatov [mailto:bounce-Arelav2@community.progress.com]
Sent: Friday, April 10, 2015 5:33 AM
To: TU.OE.Development@community.progress.com
Subject: [Technical Users - OE Development] CODEPAGE-CONVERT to UTF-32
 
Thread created by Valeriy Bashkatov

Hello,

OE: 10.2B & 11.5

I found problem with this.

This simple code demonstrate the problem:

DEFINE VARIABLE tst AS CHAR INITIAL "CONVERSION".
DEFINE VARIABLE tstutf8 AS CHAR.
DEFINE VARIABLE tstutf32 AS CHAR.
 
DISPLAY SESSION:CHARSET ": " tst FORMAT "x(76)" SKIP. PAUSE.
 
 
tstutf8 = CODEPAGE-CONVERT ( tst, "UTF-8" ). /*no problem*/
 
DISPLAY "UTF-8: " tstutf8 FORMAT "x(76)" SKIP. pause.
 
 
tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32").  /*problem here*/
 
DISPLAY "UTF-32: "tstutf32 FORMAT "x(76)" SKIP. pause.


In string with CODEPAGE-CONVERT (tstutf8, "UTF-32") I get 

SYSTEM ERROR: Memory violation. (49)
** Save file named core for analysis by Progress Software Corporation. (439)

OpenEdge has support UTF-32?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

All Replies

Posted by Dileep Dasa on 10-Apr-2015 06:41

As per documentation:

"OpenEdge supports Unicode's UTF-8 encoding. In addition, all varieties of UTF-16 and UTF-32 are supported for input and output and for LONGCHARs and CLOBs."

Posted by Garry Hall on 10-Apr-2015 07:19

To extend Dileep's answer:

The AVM treats all CHARs as encoded as -cpinternal. Your CONVERT-CODEPAGE is converting the CHAR from its -cpinternal representation to UTF-32 representation, storing it in a CHAR var. The AVM will still treat this CHAR var as -cpinternal, and since it is actually UTF-32, it mishandles the string.

What is you are are trying to do with tstutf32? If you are trying to write it out to file, you might try OUTPUT TO CONVERT TARGET "UTF-32".

Posted by Aidan Jeffery on 10-Apr-2015 07:34

What is the -cpinternal of your session?
 
If it is not utf-8, then you need to specify it as the source code page in the conversion from utf-8 to utf-32:
 
tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32", “UTF-8”).
 
 
[collapse]
From: Valeriy Bashkatov [mailto:bounce-Arelav2@community.progress.com]
Sent: Friday, April 10, 2015 5:33 AM
To: TU.OE.Development@community.progress.com
Subject: [Technical Users - OE Development] CODEPAGE-CONVERT to UTF-32
 
Thread created by Valeriy Bashkatov

Hello,

OE: 10.2B & 11.5

I found problem with this.

This simple code demonstrate the problem:

DEFINE VARIABLE tst AS CHAR INITIAL "CONVERSION".
DEFINE VARIABLE tstutf8 AS CHAR.
DEFINE VARIABLE tstutf32 AS CHAR.
 
DISPLAY SESSION:CHARSET ": " tst FORMAT "x(76)" SKIP. PAUSE.
 
 
tstutf8 = CODEPAGE-CONVERT ( tst, "UTF-8" ). /*no problem*/
 
DISPLAY "UTF-8: " tstutf8 FORMAT "x(76)" SKIP. pause.
 
 
tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32").  /*problem here*/
 
DISPLAY "UTF-32: "tstutf32 FORMAT "x(76)" SKIP. pause.


In string with CODEPAGE-CONVERT (tstutf8, "UTF-32") I get 

SYSTEM ERROR: Memory violation. (49)
** Save file named core for analysis by Progress Software Corporation. (439)

OpenEdge has support UTF-32?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by rvkanten on 10-Apr-2015 07:52

This code works fine for me under OE 11.5:

define variable test as character no-undo initial "UTF8".

define variable testutf8 as character no-undo.

define variable testutf32 as character no-undo.

assign testutf8 = codepage-convert(test, "utf-8")

testutf32 = codepage-convert(testutf8, "utf-32", "utf-8").

Posted by Valeriy Bashkatov on 13-Apr-2015 03:13

Hello,

[quote user="Aidan Jeffery"]

What is the -cpinternal of your session?

[/quote]

1251 or KOI8-RL

[quote user="Aidan Jeffery"]

 
If it is not utf-8, then you need to specify it as the source code page in the conversion from utf-8 to utf-32:
 
tstutf32 = CODEPAGE-CONVERT (tstutf8, "UTF-32", “UTF-8”).
 
 [/quote]
It's works without error :-)
Thank you very much! 

This thread is closed