Page 1 of 1

[SOLVED] Set a specific Unicode Field

Posted: Tue Jul 25, 2017 12:56 am
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?

Re: Set a specific Unicode Field

Posted: Tue Jul 25, 2017 10:59 am
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

Re: Set a specific Unicode Field

Posted: Wed Jul 26, 2017 7:48 am
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.