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.
12-15-2014 02:50 PM
Using LV 2010. I have an application where I'm encrypting a file and saving it to the hard drive as a text file. The problem I'm having is that the string of characters that I'm writing to the file does not match the string of characters that are read from the file. The files match for the first 10 characters, then in the original string, there is a \r character that is dropped from the file. The rest of the file doesn't match too well after that. Also, the size of the strings are different too by a few thousand characters. Is there some setting in the file read or write that could be causing this? Thanks.
Solved! Go to Solution.
12-15-2014 03:06 PM
Right-click your Read/Write to Text File functions and uncheck 'Convert EOL'. Or use the Read/Write Binary functions.
12-15-2014 03:10 PM
I've done that already. Also, I think I had the issue reversed. It's the original text that does not have the \r in it, but the text read from the file does. That is really weird.
12-15-2014 03:18 PM
Upon closer examination, it appears that whenever the original encrypted file contains either a \r or a \n, the write to the file automatically changes them to \r\n in every case. I wonder if there's a way to stop this.
12-15-2014 03:30 PM
@rickford66 wrote:
It's the original text that does not have the \r in it, but the text read from the file does.
Are you inspecting the raw file or are you reading it back using LabVIEW?
(If you are using LabVIEW for reading, you of course need to disable convert EOL here too, or use the binary file IO).
You typically get much better help if you include a simplified version of your code. 😄
12-15-2014 03:31 PM
String to U8 array and write read binary as Darin suggested (he is often correct;)
12-15-2014 03:32 PM
@JÞB wrote:
String to U8 array and write read binary as Darin suggested (he is often correct;)
You can wire strings directly to the binary file IO functions. No need to convert to U8.
12-15-2014 03:34 PM
I have convert EOL unchecked on all reads and writes. Right now, I'm down to creating a string, writing it to a file, reading it back from the same file, and comparing it to the original. If I can get a moment, I'll try to make up a small .vi that demonstrates the behavior.
12-15-2014 03:45 PM - edited 12-15-2014 03:52 PM
Here's a quick example (LabVIEW 2010). Result is always true in my limited testing.
Here's the string IO version:
(It is a bit more complicated when using the binary file IO:
(1) wire false to prepend array or string size when writing.
(2) wire -1 to count when reading.
This code is not attached, just a picture)
12-15-2014 03:50 PM
Augh, I found one of my read/writes that still had the convert EOL checked. How embarrassing. I went through them twice and didn't see it. Apparently I have to check things 3 times. Thanks everyone. Sorry about that.