Read single character from uni-string

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
5 posts • Page 1 of 1
hbraun
Posts: 15
Joined: Wed Aug 09, 2017 7:25 am

Read single character from uni-string

Post by hbraun »

Hello,

I use WinCC-OA 3.16P11.

Is it possible to read a single character from an uni-string. Adressing characters with [index] seems to work byte-wise only.

For example reading the 3. character ("ö") from string "aböcd" does not work with string[2]. Also I could not find any uniStr-function that has this functionality.

Use-case is to make a filter-string from the original string that ignores case with patternMatch(), for example the filter string for "aböcd" would be "[aA][bB][öÖ][cC][dD]".

Is there any way to achieve this?

Kind regards

dvribeira
Posts: 24
Joined: Mon Mar 18, 2019 11:53 am

Re: Read single character from uni-string

Post by dvribeira »

Why not

Code: Select all

substr(your_string_var, 2, 1)
?

From P013 onwards you could also use:

Code: Select all

your_string_var.mid(2, 1);
or

Code: Select all

your_string_var.at(2);
But they will always return a string type, obviously. Not sure if that might be a problem for you.

hbraun
Posts: 15
Joined: Wed Aug 09, 2017 7:25 am

Re: Read single character from uni-string

Post by hbraun »

Thank you, uniSubStr() works fine. When searching for uni-string functions in the help I searched for "uniStr*" so I did not find it...

dvribeira
Posts: 24
Joined: Mon Mar 18, 2019 11:53 am

Re: Read single character from uni-string

Post by dvribeira »

Indeed, sorry, uniSubStr instead of substr. The other two introduced with P013 work on the unicode character level and not on bytes, so they would be good for this as well.

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Read single character from uni-string

Post by gschijndel »

Also the 'strwalk' function should be able to read a single Unicode character.

Post Reply
5 posts • Page 1 of 1