Non ASCII characters

Hello,

I have a Question about using WSTRING. How I can operate with WSTRING? I need to use Czech characters like “ěščřžýáíé”. I am not able to write any of these characters to watch (it’s just no typing).

AS 6.7:

  • Var def: obrazek
  • Watch: obrazek
  • MappView: obrazek
  • Var def in AS Code: obrazek

AS Code: Always bad

  • AS Code: obrazek
  • AS Code after reopen: obrazek
  • Var def in AS6.7: obrazek or obrazek
  • Watch: obrazek
  • MappView: obrazek

MappView: It’s for now only way, how to write it.

  • MappView: obrazek
  • Watch: obrazek - It’s showing correct!!!

Some tips, how to do it correctly? Using *.tmx files? I need it to use it also in ladder program.

If you use mappView, you should use tmx files.
tmx files are utf8 and you can watch the strings in mappView.
In the AS-watch the string is only visible after converting it to c null terminated string with functions from the AsHttp library (httpUtf8ToString()).

Ok. I solve MappView to use tmx files, so use string and ‘$$IAT/…’ and it’s PLC language independent :slight_smile:

But it’s not solving using it in PLC program without MappView. I try “ArTextSysGetText”, but’s it’s not user friendly. I want some way, how to write in program/watch “ěščřžýáíé” without tmx and converting utf-8 to wstring in program.

Hi @NovotnyJ ,

i am not sure if i fully understand your question …

WSTRING is just a container for two-byte characters and doesn’t say anything about the character encoding inside.

So it’s up to the corresponding HMI, Browser, Client etc. what characters are shown.
Typicall today’s Software expects Unicode – Wikipedia or UTF-8 – Wikipedia.

You can see what’s inside a WSTRING by overlaying it by an UINT - array:

```
VAR
unicode : REFERENCE TO ARRAY[0..19] OF UINT;
MyWstring : WSTRING[80];
MyString : STRING[80];
END_VAR
```

The AS editors are not capable to handle two-character text files.
To my knowledge AS uses Windows-1250 – Wikipedia (some editors call that ‘ANSI’):

Since also the watch window can only interprete 1-byte strings it shows the hex digit instead, e.g. ‘š’ is $9a = 154 dec in Windows-1250 codepage.

→ you have to use the ‘$xxxx’ method in watch window

Hi @christoph.hilchenbac ,

I understand unicode, but I know the way, how to write it in code like var := "ěščřžýáíé" or in watch without $xxxx.

I try to copy string from watch and paste after and it’s break whole string. I have hope, that there is some way, how to do it, because the monitor show it correctly, but how do it in reverse.

I tried experimenting a little more. The Watch window obviously uses ISO 8859-1 – Wikipedia for WSTRING.

Some of the Czech characters are in there but not all.

There is a range of values that is not defined and AS uses the hex representation here.

The right codepage for Czech is ISO 8859-2 – Wikipedia.

But: when using STRING all characters can be seen. So it seem to use Windows-1252 – Wikipedia - that’s weird.

I’m a little at a loss here. This seems like something you should take up with your local B&R support team.

(Edit: tests were done with AS 6.7.0.187 in German Windows 11)

HI @NovotnyJ , is your issue answered? can you update us with final conlusion and maybe mark it as a solution?

If I remember good, I skip using Wstring like this and instead of this I am using text system ‘$$IAT/..’ for all.