unicode and progress

Posted by jmls on 02-Apr-2014 03:38

I18n noob here, so perhaps a really basic question ;)

I have a character that is represented in json by \u0100 , which is Ā

how do I turn this into a character in progress ?

All Replies

Posted by mallen on 02-Apr-2014 06:33

Complete frig, do a double conversion assuming an "feff" BOM. Probably not one for the purist in you.

define variable char1 as longchar no-undo. 
define variable char2 as longchar no-undo.

define variable int1 as integer no-undo.

int1 = 256. /* \u0100 = feff0100 = 100(hex) = 256(dec) */

fix-codepage(char1) = "utf-8". 
fix-codepage(char2) = session:charset.

char1 = CHR(int1, "utf-8", "utf-16").

copy-lob from object char1 to object char2.

/* see the result */
copy-lob from object char2 to file "char.txt" no-convert.


Posted by Garry Hall on 02-Apr-2014 08:09

I don’t understand the exact problem, so my answer might miss the mark. If the json source is correctly formatted json, and your –cpinternal can handle the character, then the ABL JSON method/object you are using to process the json should automatically convert from the escaped representation to the character.
 
A small code snippet showing the problem might help.
 
[collapse]
From: jmls [mailto:bounce-jmls@community.progress.com]
Sent: Wednesday, April 02, 2014 4:39 AM
To: TU.OE.Development@community.progress.com
Subject: unicode and progress
 
Thread created by jmls

I18n noob here, so perhaps a really basic question ;)

I have a character that is represented in json by \u0100 , which is Ā

how do I turn this into a character in progress ?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by jmls on 02-Apr-2014 09:53

You are perfectly correct in your statement, with one small caveat .. The only reason why I am doing this is because I have to use 10.2B ... :( 11 would be a cinch

Posted by Garry Hall on 02-Apr-2014 10:10

Yes, I had not appreciated the context of your other threads until after posting.
 
I don’t know of another ABL statement/function in 10.2B that will unescape JSON syntax for you. The compiler will convert literals of ~uXXXX and ~UXXXXXX to their char equivalents, but that is not going to help you at runtime. You’d have to do it manually.
 
[collapse]
From: jmls [mailto:bounce-jmls@community.progress.com]
Sent: Wednesday, April 02, 2014 10:54 AM
To: TU.OE.Development@community.progress.com
Subject: RE: unicode and progress
 
Reply by jmls

You are perfectly correct in your statement, with one small caveat .. The only reason why I am doing this is because I have to use 10.2B ... :( 11 would be a cinch

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

This thread is closed