Chinese Chars in PLC variables

Hello,

we have to store some strings with Chinese characters in the PLC.

I tried to write via Watch to a WSTRING and a STRING variable a Chinese character but it is inserted always as a ‘?’.

Is there anyone that has experience with this stuff? How do you manage them?

many thanks in advance

Marco Sartori

Hi Marco,

If you want to use Chinese characters you must use WSTRING as you are doing.

However, as far as I know AS editors/Watch window don’t support no Unicode font rendering, so every non-ASCII turns into a ‘?’. You can write Chinese characters from HMI (mapp View or VC) and this WSTRING variable will save this text. But on Automation Studio editors you will just see ‘??’.

Best regards,

Xabier

2 Likes

Hello,

You have to use WSTRING with UCS-2 and UTF-16 encoding.

Kenichiro

2 Likes

hello

I have another question. is there function that allow to perform concatenation or string trimming with WSTRING vars?

I’ve not experience and passing from STRING to WSTRING seems to be complicated.

Many thanks in advance

Marco Sartori

Hi,

AsBrWstr does the same for WSTRING as AsBrStr for STRING.

https://help.br-automation.com/#/en/4/libraries%2Fasbrwstr%2Fasbrwstr.html

Best regards!

Thanks @alexander.hefner

I was looking for it, but it seems not fully compatible with ST.

for example the first params request the string pointer, that normally is an UDINT, but in this case requests UINT.

So I cannot write: FirstSpaceChar := brwcschr(ADR(SysDesc), " ");
and the memory address should exceed the byte 65.535

Am I doing some error?

Marco

Hi @mSartoriOptrel,

I can’t check it right now, but for example for brwcscat() the help mentions that the parameters are pointer to UINT.
That means it’s like with brsstrcat still a pointer (UDINT), but it points to a UINT (wide character “array” of 16bit values) instead of a USINT (ASCII character “array” of 8 bit values)

There is a difference in a FUB requiring an UINT and one asking for a Pointer to an UINT.
Where my tries are failing is rather the “symbol” input (i have never used WSTRING before…

ADR(SysDesc) works just fine, what doesn’t work is the " " - at least here

2 Likes

You are right @michael_w

Sorry for the stupid question @alexander.hefner

Thanks for the clarification

@mSartoriOptrel,

nothing stupid there, you’re welcome :smiley: Thanks for giving us the update!