LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Typing Unicode string

Hi All,

I am trying to type Unicode strings in LabVIEW 2015. It isn´t working properly though, sometimes the characters are weirdly converted into random Chinese signs, sometimes whole LabVIEW crashes. I already went through https://forums.ni.com/t5/Reference-Design-Content/LabVIEW-Unicode-Programming-Tools/ta-p/3493021 and plenty of other sites, but none of them is specifically dedicated to how to properly input Unicode characters from keyboard. Any help would be appreciated.

0 Kudos
Message 1 of 7
(3,300 Views)

It's not entirely clear what you are trying to do.  Most (all?) US Keyboards output 8-bit ASCII (or ANSI) characters.  Unicode using U16 representations for each character.

 

If you have a U8 (Ascii) string, it is very easy to transform it into its Unicode counterpart -- simply make the high byte 0.  Similarly, if you are given a Unicode String, you can get its Ascii equivalent by throwing away the high bytes.  I've written a little routine to do this, as I have some routines that output Path Information in Unicode.  Note that you can easily tell an Ascii String from a Unicode String -- just detect if (any) of the high bytes is 0.  My routine throws away all 0 bytes (as I don't expect any NULL characters in an Ascii string) and also sets a "May be Unicode" flag if any 0 bytes are detected.

 

Bob Schor

0 Kudos
Message 2 of 7
(3,262 Views)

@Bob_Schor, there are Arabic  and Chinese keyboards. There are also software tools that simulate this, and 'type' Unicode characters.

 

CG LabVIEW just doesn't fully support Unicode. As mentioned in that link:

Disclaimer: LabVIEW for Windows has limited support for Unicode strings in the front panel controls and indicators.

 

I'd say it just won't work.

 

Depending on what you are doing, you might give NXG a try. Unicode support is one of things where it will beat CG, even now.

0 Kudos
Message 3 of 7
(3,248 Views)

If you only need to support one language at a time, I've had much better luck using the "Language for non-Unicode programs" setting in Windows rather than trying to use unicode in LabVIEW (because unicode support in LabVIEW is not great). Take a look at this library: https://github.com/JKISoftware/JKI-Simple-Localization

0 Kudos
Message 4 of 7
(3,229 Views)

I just finished converting a large project to unicode support English/Russian.

For a string control, I can not set "Update Value while Typing" like NI document suggested, otherwise when typing fast, string doesn't display correctly.  Without that setting, it will display a space between characters, until the value change event gets triggered.

No crash for string control after build into exe.

 

 

George Zou
0 Kudos
Message 5 of 7
(3,211 Views)

I am trying to create an application that has Unicode String controls and Labview keeps crashing when someone is typing a unicode string (Arabic) into the Labview String Control. This happens immediately after a space is entered, because the String is in Force Unicode display, each character typed is 2 bytes, but when a space is entered it is created as a single 1 byte 0x00 Hex instead of 0x0000. This crashes Labview immediately, regardless if it is the development version or the built executable that is being used, they both crash. Any solution to this ?

0 Kudos
Message 6 of 7
(2,595 Views)

@MMKGE wrote:

I am trying to create an application that has Unicode String controls and Labview keeps crashing when someone is typing a unicode string (Arabic) into the Labview String Control. This happens immediately after a space is entered, because the String is in Force Unicode display, each character typed is 2 bytes, but when a space is entered it is created as a single 1 byte 0x00 Hex instead of 0x0000. This crashes Labview immediately, regardless if it is the development version or the built executable that is being used, they both crash. Any solution to this ?


I think the only reliable way to do things like this, is to set you computer to Arabic, and make sue the language support for legacy applications is set to the Arabic code page.

 

That would avoid Unicode all together. (EDIT: LabVIEW's Unicode support that is, of course Unicode is used through the MBSC mechanism.)

 

I find that the little Unicode support LabVIEW offers is limited, unstable and hard to use. It seems to work OK-ish for indicators, but user input is buggy at best.

 

Still hoping someone proves me wrong...

0 Kudos
Message 7 of 7
(2,583 Views)