LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to byte array bug

I really have no idea why the string control is considering the input as 2 characters. I am pressing Alt and typing 0153. Not sure if the issue is related to keyboard, because I am typing on a laptop.

 

@altenbach - I am making a commercial application and cannot ask the user to type the hex value of the character. 

0 Kudos
Message 11 of 15
(625 Views)

@LVCoder wrote:

I really have no idea why the string control is considering the input as 2 characters. I am pressing Alt and typing 0153. Not sure if the issue is related to keyboard, because I am typing on a laptop.

 

@altenbach - I am making a commercial application and cannot ask the user to type the hex value of the character. 


It might be yopur keyboard. When I tried to look at your issue whenever I type Alt+153 (numpad) I ended up with the character Alt+214. THis happened even in Notepad so it is not a LabVIEW issue. As stated above, character encoding can be very tricky to get right.

 

Update: Alt+0153 works in Notepad and LabVIEW for me.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 12 of 15
(609 Views)

LVCoder wrote:

@altenbach - I am making a commercial application and cannot ask the user to type the hex value of the character. 


And having to ask the user to input alt+4 numbers is simpler how? How many different special characters do you need? Maybe you can make a small LabVIEW keypad containing all the special characters you need? 

0 Kudos
Message 13 of 15
(595 Views)

@altenbach wrote:
And having to ask the user to input alt+4 numbers is simpler how? How many different special characters do you need? Maybe you can make a small LabVIEW keypad containing all the special characters you need? 

I know typing Alt+4 letters isn't easy in any sense, but its a standard. I do not have any specific list of the special characters. I just want to support the complete ASCII range of values.

 

Thefunny thing is even though the string control is displaying the trademark symbol correctly, it is interpreting it as 2 characters. 

0 Kudos
Message 14 of 15
(592 Views)

@LVCoder wrote:

Thefunny thing is even though the string control is displaying the trademark symbol correctly, it is interpreting it as 2 characters. 



As I mentioned before, the issue is with the encoding that LV is using, it can change on the fly.  My guess is that you used copy/paste from a program like Character Map or Word or Notepad to enter a value.  The LV document on Unicode issues the following warning:

 

Note: The state of the InterpretAsUnicode property of a string element may be changed dynamically if text is pasted or entered into the text element by the user. The display mode (InterpretAsUnicode) of the text element will automatically adapt to Unicode or ASCII depending on the type of text entered into the control.

 

•    If you paste a Unicode string into a text element the InterpretAsUnicode property is turned on.

•    If you paste a regular ASCII string into a text element the InterpretAsUnicode property is turned off.

 

Very easy to demonstrate this:

 

Create a byte array with the values 0x22 and 0x21 (34,33).  Use Byte Array to String to display it.

Run the VI:  You see "!

Empty the string indicator

Open Character Map : Run charmap or find it in System Tools.  Choose Arial Unicode MS for the font, select some Kanji character.  Copy and paste into the string indicator.

Run the VI:  You see the trademark

Empty the indicator, type 'abc' into it.

Run the VI:  You see "!

 

Unless you take charge of the encoding, it is possible for LV to do some strange things to you.

0 Kudos
Message 15 of 15
(582 Views)