07-01-2019 08:13 AM
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.
07-04-2019 10:00 PM
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
07-05-2019 03:26 AM
@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.
07-05-2019 12:39 PM
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
07-06-2019 08:28 AM
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.
02-28-2021 10:45 PM
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 ?
03-01-2021 02:50 AM - edited 03-01-2021 02:56 AM
@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...