Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on April 03, 2020, 06:20:44 AM

Title: Unicode Conversion
Post by: RBPLC on April 03, 2020, 06:20:44 AM
Does the BRX have any kind of built in ability to translate Unicode values? If not, is there a relatively straightforward way to accomplish this?
Title: Re: Unicode Conversion
Post by: franji1 on April 03, 2020, 09:53:05 AM
To enter directly in Designer, no.  In the PLC, they're just BYTEs, so the PLC does not care.  Definitely encode as UTF8 to get it to work more easily vs. UTF16.

In Designer, use the $HH escape sequence in string literals to encode high ascii (e.g. 0x80 or greater)

U+00A9
c2 a9
COPYRIGHT SIGN


"The next letter is copyright symbol $C2$A9"

I just read that UTF8 endian-ness doesn't matter.  It's raw bytes, MSBYTE...LSBYTE, so $C2$A9 is correct, which makes sense.
Title: Re: Unicode Conversion
Post by: RBPLC on April 03, 2020, 04:02:13 PM
Is there a way in DmD to cast a string? For example, SS0:2. If not, which command provides to closest to this functionality?
Title: Re: Unicode Conversion
Post by: franji1 on April 03, 2020, 04:13:06 PM
Put the string into a BYTE data block using STRGETB - Get BYTEs Out of a String.  STRGETB SL0 MyByteBuff0 SL0.Length
Now you have MyByteBuff0 MyByteBuff1 MyByteBuff[V0] and can access the data easily.

To put it back, do STRPUTB MyByteBuff0 SL0 NewLength
(Put BYTES Into a String)