LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect Null characters in a binary string

Solved!
Go to solution

In my application, I'm sending around true binary data in strings and flattened data structures and sometimes I get null characters in the string. I was wonder if there is a way to dectect NULL characters in a string. Thanks for your help.

 

Josh

0 Kudos
Message 1 of 3
(10,006 Views)
Solution
Accepted by topic author E=McHammered

Josh,

 

A null character is hex 00.  If you use Match pattern and make the search string a null, it should find it.  To enter a null set the control or constant to '\ Codes' display and type in 00.

 

Another way is to convert the string to an array of U8 and search the array for 0.

 

Lynn 

Message 2 of 3
(10,000 Views)

E=McHammered wrote:

In my application, I'm sending around true binary data in strings and flattened data structures and sometimes I get null characters in the string. I was wonder if there is a way to dectect NULL characters in a string. Thanks for your help.

 

Josh


There are various ways to do that:

 

1) convert the string into a byte array and look for 0 bytes in there.

2) Using Match Pattern function and a search string containing \00 (enable backslash codes in the popup menu)

3) If it is about replacing/removing them, using the Search and Replace String function and again \00 as search string

4) - 99) various variants and functions in LabVIEW using advanced regualr expressions etc.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 3 of 3
(9,998 Views)