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.
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.
03-23-2017 03:58 PM - edited 03-23-2017 04:13 PM
Hello,
I am getting a very weird issue when I get a binary value out of a database and cast it to a string. If I use an indicator to show the string it looks ok, with what appears to be spaces in between characters. However, the spaces actually seem to be something else, string functions do not recognize them as spaces and neither does probing them.
As you can see, the value is shown simply as "[" while the probe indicator shows my full string as "[ 9 ] [ 1 ]". Does anyone have any idea what issue I am running into?
EDIT: I have included a very quick VI to illustrate my issue. It simply passes my weird string from control to indicator. Visually it appears fine, but if you probe the wire in between you'll see the issue. Also, if you copy and paste from the indicator or control into another program you will also see the issue.
Thank you very much,
Solved! Go to Solution.
03-23-2017 03:58 PM
Hello,
I am getting a very weird issue when I get a binary value out of a database and cast it to a string. If I use an indicator to show the string it looks ok, with what appears to be spaces in between characters. However, the spaces actually seem to be something else, string functions do not recognize them as spaces and neither does probing them.
As you can see, the value is shown simply as "[" while the probe indicator shows my full string as "[ 9 ] [ 1 ]". Does anyone have any idea what issue I am running into?
Thank you very much,
03-23-2017 04:01 PM
91 decimal is the equivalent to the ascii character "["
03-23-2017 04:08 PM
Hmm, you might be on to something here. However, if I show my string in a string indicator it appears correctly as "[ 9 ] [ 1 ]". The probe window I showed is actually probing a string "wire", so the conversion has already taken place.
However if I copy the string from the indicator and paste it here it appears as just "[". Thanks for the reply, that gives me an idea or two.
03-23-2017 04:24 PM
So, I sort of resolved my issue although I am still really curious I was seeing what I was seeing. Seems as if the "spaces" I was seeing had binary values of 0, instead of 32 which is ascii for space. When I removed those ghost characters everything works fine.
03-23-2017 05:04 PM
Did you notice that every other character is a null (a zero value)? Have you ever heard of Unicode, a string encoding mechanism that uses 16 bits to represent a character rather than the 8 bits that ASCII uses? Perhaps your string is being saved as Unicode, which is the simplest explanation for what you are observing.
Bob Schor
03-24-2017 08:01 AM
Bob,
I think you are right. I got the string included in my posts out of a database created by TestStand. If I go to the database schema configuration dialog, it shows the entry I am interested in as datatype "String(BTSR)". When I read about BTSR I see that a BTSR is a null-terminated Unicode string, with a byte count. I think my issue presented itself because when I read the BTSR string out of the database I read it out in raw binary, then used labview to convert it back to text. When I request it as an actual string from the database it comes in just fine.
Thanks for your input,