News:

  • September 22, 2026, 12:03:57 PM

Login with username, password and session length

Author Topic: Unicode Conversion  (Read 8041 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Unicode Conversion
« 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?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Unicode Conversion
« Reply #1 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.
« Last Edit: April 03, 2020, 09:55:15 AM by franji1 »

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Unicode Conversion
« Reply #2 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?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Unicode Conversion
« Reply #3 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)