From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing chinese and english characters to a file

Is it possible to combine Chinese and English text in a string and write it to a file? I have a vi that creates an XML file, we want to add support for Chinese characters. I've got the Chinese characters working now but when I concatenate it with English text it changes all the text to Chinese. 

0 Kudos
Message 1 of 5
(2,995 Views)

Is it a manual XML write or a premade XML routine?  If it's manual, can you write the text as 3 separate strings?

 

Also, maybe try using the "String to byte array" node, then concatenate all 3 arrays, then convert back to a string?

 

(I don't have support for Chinese set up so I can't test it myself...)

0 Kudos
Message 2 of 5
(2,944 Views)

Chinese character uses 2 bytes, while ASCII is single byte.  You have to convert ASCII to multi-byte first.

Take a look unicode:

https://forums.ni.com/t5/Reference-Design-Content/LabVIEW-Unicode-Programming-Tools/ta-p/3493021

 

 

George Zou
Message 3 of 5
(2,939 Views)

As mentioned you need to buffer the constant to unicode by adding a \00 in front of every character. The easist way would be to convert the text to a U8 array and convert that to a U16 array, typecast to string and add to the chinese string.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 5
(2,923 Views)

Hi,

 

Here is an article that goes through how to concatenate English and Chinese characters into the same string. Unfortunately, LabVIEW does not fully support Unicode, so not entirely sure if it's possible to write this to a file. But if this is something that is important, LabVIEW NXG versions actually supports Unicode, so this may be a good option for this.

 

Parul M.

Applications Engineer

National Instruments

0 Kudos
Message 5 of 5
(2,742 Views)