unicode characters

This is a project running with Swedish fonts on Ignition 7.9.13

We have a tag called RecipeName and for example it might contain the string: “61176 Köttfärssås till Paj”. This string shows up properly throughout Ignition and within MySQL. However, when I read that tag using and then write that tag to a Siemens S7 PLC using system.opc.writeValue, the string gets corrupted to “61176 K�ttf�rss�s till Paj”

I am not sure if the corruption is occurring at the read or write stage. If I create a button to run a read script and then print the result on the console it returns the correct value. However, if I use system.util.getLogger to log the value to the console (in Designer) it returns the corrupted string.

Any insight would be appreciated.

Ignition strings use 16-bit unicode characters. Siemens strings are 8-bits per character. Without careful application of an 8-bit codec in both directions (UTF-8, perhaps), both reading and writing will corrupt the string.

Thank you Phil. Even before I get to writing it to the Siemen’s PLC I seem to be running into an issue with just reading the tag and logging it. Of course this could be that the logger is not handling it well.

If I read the Ignition tag (as recipeName) and then encode it (recipeName.encode(‘utf8’)) before I do the opc write, do you think that will work?

There’s a chance this is an issue with our Siemens driver as well. I doubt it’s explicitly setting the Charset to UTF-8 when turning the String to bytes to write. This oversight is common in older code that deals with Strings.

Do you have any HMI products that already display extended characters from these S7 strings? If so, play with the actual bytes from such content to identify the codec. Older systems would typically pick one of the “Latin-NN” charsets to keep the string 1 byte per character. When you figure it out, try that codec on the Ignition side.