[SOLVED] Set a specific Unicode Field

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
LANSAGuru
Posts: 69
Joined: Thu Mar 24, 2016 5:31 am

[SOLVED] Set a specific Unicode Field

Post by LANSAGuru »

Does anyone know how to set a Unicode Field to a specific value in RDMLX code?

1. I do not want to read a Unicode database field from a table and move that value in, I want to set an arbitrary Unicode value like u+nnnn and cast it into a Unicode file.

2. .asSQLNativeString moves a given unicode value into a native code page (not what we want)

3. .asSQLHexLiteral is to prepare a unicode value for use in a select_sql statement

4. You can move a field in a native code page into a Unicode field easily enough, but that is not the same thing as #1

This code works =>

Define Field(#W_DESCRIPTION) Type(*NVARCHAR) Length(70) Desc('Description')
Define Field(#wknbsp) Type(*char) Length(2)
Use Builtin(HEXTOBIN) With_Args('A000') To_Get(#wknbsp)
#W_DESCRIPTION := *blanks + #wknbsp

However it is platform specific in that the little endian, big endian nature of the platform comes into play.
On windows to make this work (this is a non-breaking space) you need to us A000, on IBMi you need to use 00A0.

Questions.

1. Is there a language builtin to do this in RDMLX code?

2. If there is not, should there be?
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Set a specific Unicode Field

Post by Stewart Marshall »

Hi Paul

Doesn't AsUnicodeString get you the result you want, or have I misunderstood the requirement?

Code: Select all

#xDemoUnicode128 := "Some text" + (9999).AsUnicodeString + "More text"
Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
LANSAGuru
Posts: 69
Joined: Thu Mar 24, 2016 5:31 am

Re: Set a specific Unicode Field

Post by LANSAGuru »

Stewart,

I see why I did not find this. It is buried in the primitives definition in the doco.
It also does not define what the input is really. it appears to me to be the decimal representation of a single Unicode Character code point.

But this does work.
It does appear to return the correct Unicode value irrespective of platform.

* Unicode Character 'NO-BREAK SPACE' (U+00A0)
#wknbsp := (160).AsUnicodeString

Hey Mikey, i think he likes it.

Thanks,
Exactly what I was looking for.
Post Reply