Page 1 of 1

Chinese string from the controller

Posted: Thu Jul 04, 2013 8:27 am
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.

Re: Chinese string from the controller

Posted: Mon Jul 08, 2013 10:43 am
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.

Re: Chinese string from the controller

Posted: Tue Jul 09, 2013 6:32 am
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.

Re: Chinese string from the controller

Posted: Tue Jul 09, 2013 10:16 am
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.

Re: Chinese string from the controller

Posted: Tue Jul 09, 2013 11:08 am
by fsturlese
Thank you Mark, I will give a try.
Regards,
Federico.