Chinese string from the controller

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
fsturlese
Posts: 36
Joined: Tue Nov 22, 2011 11:57 am

Chinese string from the controller

Post by fsturlese »

Hello, we need to get a text string that is stored inside the controller, and the customer requires the support of Chinese characters.
Any way to do that?
We are targeting to PC and the controller is accessed through Modbus/TCP.
Thank you.
Best regards,
Federico.

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Chinese string from the controller

Post by mark.monroe »

Modbus only supports ASCII characters. Which means that you will not be able to natively send Chinese characters over modbus. You could create your own coding structure, where each Chinese character you want to send is represented by a different 16-bit number. Then depending on which number is sent you could use script to translate that into a different Chinese character.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

fsturlese
Posts: 36
Joined: Tue Nov 22, 2011 11:57 am

Re: Chinese string from the controller

Post by fsturlese »

Suppose that I get an Unicode UTF-8 string from the controller, in form of a sequence of two-bytes characters, and I declare a STRING[20] variable in iX: I should be able to fill in the string with 10 Unicode characters. Such string won't be visible if assigned to an ASCII text label, but it should be visible if assigned to an Unicode text label.
The problem that I see is that if I want to transfer ASCII chars this way, if I am not wrong I should set the MSB to 0 for each couple of bytes, which would lead iX to truncate the string at the first occurrence of the null char... so the question is: can I declare a UINT16 array, fill it with UTF-8 characters read from the controller, and then cast the array to a Unicode string in iX (or copy the array into a Unicode string)? Do you think it would work?
Do you know if there is a specific data type that can be used in scripts to handle Unicode strings?
Thanks,
Federico.

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Chinese string from the controller

Post by mark.monroe »

Strings in iX Dev are unicode. If you transfer the unicode as a number, then cast the number to a string, it should work. I think the easiest thing would be to treat each character as a separate number and go through your int array and cast the values element by element.

I would think that your plan would work.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

fsturlese
Posts: 36
Joined: Tue Nov 22, 2011 11:57 am

Re: Chinese string from the controller

Post by fsturlese »

Thank you Mark, I will give a try.
Regards,
Federico.

Post Reply