Null Characters in Flatten to String
Hi all,
I am using the Flatten to String Function to convert a numerical array to a flattened data string in hexadecimal. When I do this, it adds 6 null characters (zeros) before every array element. How can I flatten my array without the addition of these null characters?
Thanks,
Jasmine
Solved!
Go to Solution.
Now that I'm looking at your code, that can be simplified A LOT.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Flatten to String.png 25 KB
Similar Messages
-
How to detect Null characters in a binary string
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
Solved!
Go to Solution.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
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Flatten to string for sending through TCP/IP contains CRLF characters
Hi,
I'm using a 'flatten to string' function to send some data through TCP/IP.
To minimise delays, I use the CRLF mode so that the receive function returns as soon as it receives a CRLF sequence (termination character).
I noted that every now and then only part of the data is transmitted because the flattened string itself sometimes (albeit rarely) contains CRLF characters.
I was wondering if this is correct behaviour, or if I'm missing something.I expected flatten to string to produce pure ASCII strings without special characters.
Now I first have to scan the string and replace possible CRLF characters by some known series of characters and do the opposite on the receiving side, and hope that this particular sequence never occurs.
Any comment is appreciated,
Manu
Certified LabVIEW Developer (CLD)
Solved!
Go to Solution.mkdieric wrote:
Hi,
thanks for the feedback. I'll use the way you describe, by first sending the number of characters to expect.
Manu
Make sure you are consistent with the format for the number of butes. That is, always use an 8, 16 or 32 bit value. Which one you use is up to you and will depend on the size of your data. A 32 bit value is the most common size to use. Anyway what I am basically saying is that if you are inconsistent with what size number you use for the size you will get inconsistent results when you read the data since you will be interpretting the size incorrectly some of the time.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot -
IDOC Data record is appending with NULL characters instead of spaces.
Hi Gurus,
1) We have created a port with Japanese characters for MATMAS05 (IDOC type) and trying to download an IDOC into an XML file using the ADAPTER, the actual data is less than the length of the IDOC string so we need to append the remaining spaces to each data record which in turn fills the segment pad but whereas in NON-UNICODE server the data record is appending with NULL characters instead of spaces.
2) For Japanese port the receiver port name in XML file is appearing with some junk characters in NON-UNICODE client, whereas in UNICODE client it is displaying the correct port name with Japanese characters.
Your help will be appreciated.
Thanks in Advance.ORA-06512 indicates a numeric or value-error line 2 seems to show to the first statement.
Check the datatypes of your columns/items.
Try to issue an update manually in SQL*Plus to see if it works generally. -
HI FRENS,
kindly tell me how to remove null characters from a string
thanks in advanceHi,
you mean space?
In this case:
replace all occurrences of space in string with ''.
rgs -
Match pattern and null characters
Hi,
I'm using LabView 2010 and want to write a VI that imports a spreadsheet file (txt) into an array, and then goes through the rows and looks for expressions.
Problem:
The "read from spreadsheet file" vi generates unnecessary spaces and empty rows and the data apparently contains null characters, so that the "match regular expression" vi returns only errors.
What is a null character and how do I get rid of it and how can I import the text file properly without the additional spaces and empty lines?
Thank you.
Original text file:
Text file imported into an array (note the spaces and empty rows):
vi:
Solved!
Go to Solution.This file is not an ASCII text file but really an UTF16 file. As such the ASCII String to Spreadsheet file obviously has to run into problems trying to interpret it. A quick and dirty approach would be to read in the file as string first, remove the first two UTF16 file indication bytes and then remove every second character. If the file does only contain 7Bit ASCII characters you are all done and can feed the resulting string to Spreadsheet String to Array, otherwise you will get some strange characters at the positions that contain non 7Bit ASCII characters.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How to find number of characters in a character string
Hi,
Can anyone please tell me about how to find the number of characters in a character string type variable.
Reagards,
Sivahi,
Use STRLEN for Calculating String Length..
Assign it to integer variable for Further Use.Suppse u need to find string length for "hai".. this piece of code will help u
data: var type string value 'hai',
len type i.
len = strlen(var).
write len. -
Data type of preprend array size in Flatten To String block
Hi
The data type of the preprend array size in Flatten To String block is given as I32. Is it somehow possible to reduce the data type to I8, since the width and height of my array won't exceed 255 ?. I also need to do the same in Unflatten To String as well.
Best regards
OesenOesen wrote:
Hi
The data type of the preprend array size in Flatten To String block is given as I32. Is it somehow possible to reduce the data type to I8, since the width and height of my array won't exceed 255 ?. I also need to do the same in Unflatten To String as well.
The short answer is no. This is because the index is an I32. NI likes to keep integers as an I32 whenever possible for reasons like this.
Since you are dealing with a 2D array (width and height), it will actually use 2 I32s before the actual data.
As Ravens stated, you could put in your own array sizes before the array in the string. But it is worth saving 6 bytes? Not likely.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Getting null value while parsing "XML String" with encoding WINDOWS-1252.
Hi,
when I am converting the Follwoing "xml string " to Document, I am getting the "null" as a document value.
String strXML = "<?xml version="1.0" encoding="WINDOWS-1252"?>
<category name="SearchByAttributes" value="Search By Attributes">
<item name="ORDER_LINE_ID" description="Application Search Attributes" >
<attribute name="Sequence" value="0001"/>
</item>
</category>"
My "xml string" has the encoding vaule: WINDOWS-1252.
I am using the following code to convert the "xml string" to Document. I am getting the Document values as a "null" while converting the above "string xml"
String strXML = //my above string xml.
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setIgnoringElementContentWhitespace(true);
docBuilder = docBuilderFactory.newDocumentBuilder();
doc = docBuilder.parse(new InputSource(new StringReader(strXML)));
System.out.println("doc value.."+doc)//I am getting null value for "doc".
Can anyone help me to resolve the issue.Thagelapally wrote:
I am coverting the below "XML string" to Document, once it is converted I am reading that Document,which have an "attribue" Element in.
String strXML = "<?xml version="1.0" encoding="WINDOWS-1252"?>
<category name="SearchByAttributes" value="Search By Attributes">
<item name="ORDER_LINE_ID" description="Application Search Attributes" >
<attribute name="Sequence" value="0001"/>
</item>
</category>" I am using the above code to read the Document. When run the code in "OC4J Server" and using Jdeveloper as an editor,I am able to perfectly read the "attribute" element in the document with out any problem.Println statement printing as I expected.
System.out.println("Element Name..."+listOfAtt.getNodeName());
//getting Element Name as...."attribute"(as expected)
System.out.println("Element Attibrute list....."+elementAtt);
//getting Element Attribute list as an...."oracle.xml.parser.v2.XMLAttrList@afe"But when run the same code(reading the same Document) in Tomcat and Eclipse,println satatement not printing as i expected.
System.out.println("Element Name..."+listOfAtt.getNodeName());
//getting Element Name as...."#text"(I am expecting output value "attribute" but it is printing "#text" which i don't know)
System.out.println("Element Attibrute list....."+elementAtt);
//getting Element Attribute list as an...."null"(I am expecting output value object reference but it is printing "null"
(without the rest of the code, i'm guessing that) most likely you are grabbing the first child node of the item element. however, you are not accounting for some text nodes that are most likely in that list, like the whitespace between the item element and the attribute element. please go read some tutorials on xml, there are thousands of them out there, and they will answer all you initial questions much more efficiently than posting each step to the forums. -
How to Identify the Same Characters in 2 Different Strings
Hi All,
I am requiring a suggestion on how to identify the same characters in 2 different Strings, for example:
String str1 = "hello";
String str2 = "llheo";
Both Strings contain the same characters, but in a different order, so what would be the best technique to verify t that both Strings indeed contain the same characters?
I was personally thinking along the lines of using the class, java.util.regex.Pattern?
Any thoughts would me much appreciated. ThanksI would instead sort the characters, and then compare
the sorted data.
I'm fealing generous
private static boolean anagram(String left, String right)
if (left.length() != right.length())
return false;
char[] leftChars = left.toCharArray();
char[] rightChars = right.toCharArray();
Arrays.sort(leftChars);
Arrays.sort(rightChars);
return Arrays.equals(leftChars, rightChars);
} -
Null characters in the source file
Hi frnds,
We have a file to file scenario, where in R/3 system will generate the flat files and put in the some folder of R/3 system itself. XI needs to pick this file and process but the problem here is the file contains every alternate character as null character i.e., 1st,3rd,5th.. and so on. Whic is failing during mapping.
Following is the error message displayed:
*com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:4, col:12) at java.lang.Throwable.<init>(Throwable.java:56) at com.sap.aii.utilxi.misc.api.BaseRuntimeException.<init>(BaseRuntimeException.java:58) at com.sap.aii.mappingtool.tf3.Transformer.checkParserException(Transformer.java:187) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:174) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:64) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:92) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:95) a.............t *
Please can any one help how to handle this file with null characters.
Regards,
Shiva.HI,
On source side make all those fields as optional i.e. occurance will be 0..1 or 0...Unbounded.
Also while mapping with Receiver fields make those also optional or use DefaultValue Node to pass default value as blank space.
Actually the node is unable to generate due to Null value so that might be the problem
Thanks
Swarup -
JMS Null Characters being added to payload
Hi.
I have an application which produces jms messages to a queue.
Every message I have created seems to have 4 NULL characters pasted onto the end of the payload.
I am experiencing the same issue with deployed applications and those just connecting to the jms server from a different application outside of Netweaver.
This has only just started happening, and everything was working ok before this happened - has anyone any pointers at all??
Im very confused as to why this would happen.
Update: It also only applies to BytesMessages as TextMessage is ok.
Regards,
Andrew
Edited by: Andrew Morton on May 15, 2008 12:14 PMThis is to do with the jms framework.
The 2 ways to get the payload out of the message resulted in 2 different sizes of payload being delivered. -
NXT Flatten to String Not Working with Clusters and Arrays
Hello,
My name is Joshua and I am from the FIRST Tech Challenge Team 4318, Green Machine. We are trying to write a program that will write to a configuration file and read it back. The idea is that we will be able to write to a config file from our computer that will be read by our autonomous program when it runs. This will define what the autonomous program does.
The easiest way to do this seems to be flattening a data structure to a string, saving it to a file, and then reading back and unflattening it. The issue is that the flatten to string and unflatten from string VIs don't seem to work with arrays and clusters on the NXT. It does work when running on the computer. We've tried arrays, clusters, clusters in arrays and arrays in clusters, none seem to work. Thinking it was something to do with reading the string from a file, we tried bypassing the file functionality, still not working. It does work with basic data types though, such as strings and numbers.
No error is thrown from what we can tell. All you get is a blank data structure out of the unflatten VI.
The program attached is a test program I've been working on to get this functionality to work. It will display the hex content of what is going into the file, coming out of the file, and then the resulting data from the unflatten string, as well as any errors that have been thrown. The data type we are using simulates what we would like to store. There is also a file length in and out counter. The out file is a little larger because the NXT write file VI adds a new line character on to the end (thus the use of the strip white space VI). This character was corrupting even basic data types saved to file.
I would like to know if there is a problem with what we are doing, or if it is simply not possible to flatten arrays on the NXT. Please ask if you have any questions about the code. Thank you in advanced!
Joshua
Attachments:
ReadableTest.vi 20 KBHi jfireball,
This is a very interesting situation. Take a look at what kbbersch said. I also urge you to post in the FTC Forums. You posted your question to the general LabVIEW forums, but by posting to the FTC Forums, you will have access to others that are using the NXT hardware.
David B.
Applications Engineer
National Instruments -
How to find no of numeric characters in a given string ???
How to find no of numeric characters in a given string ???
Thanks,
Kathirsabre150 wrote:
Use String.replaceAll() to replace any characters that are not numeric and then take the length of the resultant String....and this might be useful: [http://www.regular-expressions.info/]
;-) -
My Tcp/ip multi-client server is not passing the data string into the flatten to string vi
I am using labview Multi-connection cleint and server to build my own multi-client server connection.
The problem i am having is that the data does not get through the flatten to string vi. Would anyone be kind enough to tell me why is that happening? and what I do to fix it.
Attached code . My goal is to send data to the client via tcp/ip and use the data to perform certain task.
Thanks a whole lot
Attachments:
multiconnection-server.vi 39 KB
multiconnection-client.vi 21 KBInstead, I decided to upload the code and recent mods I have made to it .
see attached
Attachments:
multiconnection-clienttest.vi 43 KB
multiconnection-servertest.vi 21 KB
Maybe you are looking for
-
I forgot the security answers on my Ipod Touch 5th generation and it won't let me downlaod ANYTHING fron itunes and it's REALLY REALLY frustarting!!!!!!!!!
-
Upgrade 12.0.4 to 12.1.3
Hi All, Please advise on upgrade from 12.0.4 to 12.1.3. Let me advise to proceed with patch applications or some other way. Please help on this continue further. Environment RedHat Linux 5. 32bit. Thanks, Vasanth
-
IMP:Forecast Consumption/Netting by incoming Sales orders in SNP
Dear All, I need your help to understand the logic of Forecast netting by Sales orders in SNP. I can see the details in /SAPAPO/RRP3 but getting puzzled for soem SKUs. We don't have any PP/DS and GATP implemented. Below are the details and question b
-
Initalizing Floppy Controller-hangs
Hi, I know I have posted before and I thank everyone for their suggestions! I have a 945P Neo board w/ intel pentium D proc, 2 GB Ram, 430 W PSU w 20 A on 12V, 256 MB PCI-E vid card, SATA HD, DVD Burner, and floppy. My problem is still the same alt
-
Using an alternate display to view presenter information
I am having trouble getting my iBook G4 to run the presenter view. I have selected the option in the software preferences window but it still will not show the presenter view when I play the slideshow. I am beginning to think that my iBook is not cap