LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to byte array bug

Hi All,

I am trying to print the ascii value of the trademark symbol(ascii = 153, type it by holding Alt and type 0153 using numpad) using string to byte array, but it's returning the value 34,33. Interesting thing is it is returning 2 values.

I  am attaching the vi here. Could anyone please take a look at it and let me know if it is a bug.

 

Thanks,

Ritesh

Download All
0 Kudos
Message 1 of 15
(2,684 Views)

LVCoder,

 

I think you had the wrong characters in the control, this worked for me once I typed the correct character ALT - 0153.  -SS



0 Kudos
Message 2 of 15
(2,675 Views)

It also depends on the OS. The circled R maps to decimal 168 on the Mac.

 

Several extensions to the 7-bit ASCII set exist and not all are compatible.

 

Lynn

0 Kudos
Message 3 of 15
(2,667 Views)

You are entering two characters. Why don't you set your string control to hex display and enter 99 instead? You might also want to read this document.

 

Dumb question: If I press "alt", I cannot enter anything. It simply highlights the file menu (LabVIEW 2012)

0 Kudos
Message 4 of 15
(2,664 Views)

It is easy to send byte patterns to a string control/indicator that cause the encoding to flip out, probably what happened here.

 

For example:

Change the input of the byte array to 2 elements: [0,153]

Run the VI: 'string' shows a space (null) + trademark symbol

Copy the 'ASCII' string, paste into 'string' indicator.  Still looks like the trademark symbol.

Run the VI again:  Mojibake.

Change the input of the byte array to [34,33]

Run the VI again:  trademark

 

String Encoding+LabVIEW=Trainwreck

0 Kudos
Message 5 of 15
(2,657 Views)

Dumb question: If I press "alt", I cannot enter anything. It simply highlights the file menu (LabVIEW 2012)


Not Dumb at all, You have to be in a text field such a LV control or notepad and use the number pad.  Never tried it on my mac, I will try tonight. -SS



Message 6 of 15
(2,656 Views)

Ah, my laptop does not have a number pad... 😞

0 Kudos
Message 7 of 15
(2,649 Views)

@altenbach wrote:

Ah, my laptop does not have a number pad... 😞


Neither does mine, but it does have a Function (Fn) key which helps many of the keys serve double duty (the alternate values are tiny and colored purple).  Amongst the alternate values are the number pad keys. 

0 Kudos
Message 8 of 15
(2,644 Views)

Yes, I know it's there somewhere, but I never use it, ever.

Fn-num-lock, then use some of the specially marked keys near the right (e.g. k=2, o=6)

0 Kudos
Message 9 of 15
(2,636 Views)

Darin.K wrote:

 

String Encoding+LabVIEW=Trainwreck


Make that String Encoding + anything = headache

 

It's not that LabVIEW is particularly bad in that, just more limited than when you use for instance a C runtime library. But not so much for the worse, since getting string encoding right in a C program is a major pitta.

 

Having more freedom often isn't better especially in programming. And making string encoding right in a single platform application IS hard, making it right in a multiplatform way, is a project that nobody has fully tackled so far.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 15
(2,602 Views)