Page 1 of 1
Unicode and DBCS (RPG)
Posted: Fri Feb 20, 2015 9:34 am
by rdevost
Hi,
Would like to ask how are Unicode and DBCS being managed in LongRange RPG Online and Offline settings?
I see LRNG_AssignUniStrToProp and LRNG_GetPropAsUniStr commands in a couple of Demo exercise programs but I don't see any references in the LongRange for RPG documentation.
Thanks,
Rocel
Re: Unicode and DBCS (RPG)
Posted: Fri Feb 20, 2015 10:13 am
by MarkDuignan
They do seem to be missing from the documentation. We will rectify that.
What do you need to know?
I am assuming you have seen the 3 shipped unicode online examples?
If not - using the LongRangeDemo.LXP schema you should be able to execute Programming Examples -> Use Case Examples -> Unicode Output, Unicode Input and Useful Unicode Characters.
You can display or email the code by using the ‘Display RPG Code’ option in the overflow menu on top right.
The shipped example RPG source code should be in file LRNG_DEMO/SOURCEEXAM in members EXAM0014, EXAM015 and EXAM027.
Re: Unicode and DBCS (RPG)
Posted: Fri Feb 20, 2015 10:31 am
by MarkDuignan
These are the API prototypes defined in LRNG_SOFT/LRNGSOURCE member LRNGCOMMON.
They work just like non-UniCode APIs - except that the value parameter must be a Unicode type of field
Code: Select all
*-------------------------------------------------------------------------
* LRNG_AssignUniStrToProp
*-------------------------------------------------------------------------
D LRNG_AssignUniStrToProp...
D pr
D Value 16383C varying const
D A1 256A varying const
D A2 256A varying const
D options(*nopass)
D A3 256A varying const
D options(*nopass)
D A4 256A varying const
D options(*nopass)
D A5 256A varying const
D options(*nopass)
D A6 256A varying const
D options(*nopass)
D A7 256A varying const
D options(*nopass)
D A8 256A varying const
D options(*nopass)
D A9 256A varying const
D options(*nopass)
D A10 256A varying const
D options(*nopass)
D A11 256A varying const
D options(*nopass)
D A12 256A varying const
D options(*nopass)
Code: Select all
*-------------------------------------------------------------------------
* LRNG_GetPropAsUniStr
*-------------------------------------------------------------------------
D LRNG_GetPropAsUniStr...
D pr 16383C varying
D A1 256A varying const
D A2 256A varying const
D options(*nopass)
D A3 256A varying const
D options(*nopass)
D A4 256A varying const
D options(*nopass)
D A5 256A varying const
D options(*nopass)
D A6 256A varying const
D options(*nopass)
D A7 256A varying const
D options(*nopass)
D A8 256A varying const
D options(*nopass)
D A9 256A varying const
D options(*nopass)
D A10 256A varying const
D options(*nopass)
D A11 256A varying const
D options(*nopass)
D A12 256A varying const
D options(*nopass)
Code: Select all
* ........................................................................
DLRNG_SetPropertyU...
D pr extproc('LRNG_SetPropertyU')
D PropertyName * value options(*String)
D Value 16383C Varying Options(*Varsize)
Code: Select all
* ........................................................................
DLRNG_GetPropertyU...
D pr extproc('LRNG_GetPropertyU')
D PropertyName * value options(*String)
D ReturnedValue 16383C Varying Options(*Varsize)
D Length 10I 0 value
Re: Unicode and DBCS (RPG)
Posted: Sat Feb 21, 2015 2:47 am
by rdevost
Thanks, Mark.
Yes, I've already seen the 3 shipped Unicode online examples. So, coding this Unicode in an Offline setting is just the same as how you would in an Online setting? Or are there any special considerations I should keep in mind?
Thanks again!
Re: Unicode and DBCS (RPG)
Posted: Sat Feb 21, 2015 10:02 am
by MarkDuignan
All LongRange data on the client and on the server (once it gets 'outside' of your RPG program) is stored as Unicode.
'
When you set a property the RPG field value you supply is normally EBCDIC – but that gets converted to Unicode before it is stored to be later sent to the client.
he same happens when you retrieve a property into an EBCDIC RPG field. The property is located and then converted to EBCDIC in your current CCSID and mapped into your field.
If you use the “U” (Unicode) get and set APIs then that conversion from/to EBCDIC is not performed and you have to be prepared to supply or receive real Unicode data.
It’s that simple I think for both online or offline sourced data.
You can’t really pass Unicode data through the DDS fields (display files) because they get converted to and from EBCDIC.
That’s okay if your Unicode data source is Japanese (say) and you are running the 5250 session/job with a Japanese EBCDIC CCSID.
However if you wanted to display Japanese, Russian and Chinese Unicode on one screen that would be near impossible because one 5250 screen/session cannot be running in 3 different EBCDIC CCSDs at the same time – so 2 of the 3 conversions to/from EBCDIC would get messed up.
Ie: What the ‘Unicode Output’ and ‘Unicode Input’ examples show (many languages on one form view) would not be possible if the data passed through a 5250 DDS field.
Re: Unicode and DBCS (RPG)
Posted: Wed Feb 25, 2015 10:25 am
by rdevost
Thanks again Mark. Appreciate all your input.