Verifying line feed endings

L

laredotornado

Hi,

I'm looking for some advice on how to help out QA group verify that
files we our generating in one of our applications contain Windows
line endings. Specifically, I want to ensure that a particular file
contains the carriage return-line feed sequence (as opposed to Mac's
carriage return or Unix's line feed characters only).

Thanks for your help, - Dave
 
N

Nil

I'm looking for some advice on how to help out QA group verify that
files we our generating in one of our applications contain Windows
line endings. Specifically, I want to ensure that a particular file
contains the carriage return-line feed sequence (as opposed to Mac's
carriage return or Unix's line feed characters only).

I assume you're talking about text files.

I don't really understand what you want. It's up to your application's
programmers to ensure that that the program produces the right format.

Most text editors will tell you that, and will let you convert from one
form to another.

Notepad++
EditPad Lite
Crimson Editor
PFE
Vim
Aurora

are all editors I have that will do that.

You could batch run the files through a command-line text processor
like grep or perl or maybe even Windows FINDSTR to search-and-replace
the EOL characters.
 
Z

Zaphod Beeblebrox

laredotornado said:
Hi,

I'm looking for some advice on how to help out QA group verify that
files we our generating in one of our applications contain Windows
line endings. Specifically, I want to ensure that a particular file
contains the carriage return-line feed sequence (as opposed to Mac's
carriage return or Unix's line feed characters only).

Thanks for your help, - Dave

Open the files in a hex editor and look at the end of the lines for a
0D 0A character pair. I like XVI32, but there are plenty of others
out there.
 
P

Paul

laredotornado said:
Hi,

I'm looking for some advice on how to help out QA group verify that
files we our generating in one of our applications contain Windows
line endings. Specifically, I want to ensure that a particular file
contains the carriage return-line feed sequence (as opposed to Mac's
carriage return or Unix's line feed characters only).

Thanks for your help, - Dave

You can use a gnuwin package for that. The "file" command,
is a port of the file command from Linux/Unix, which searches
inside a file to determine the file type. In other words, it
ignores the file extension, and tries to guess the file
type by reading a fraction of the file. These ported
packages run in a Command Prompt window in my WinXP.

http://sourceforge.net/projects/gnuwin32/

Look in the "View all files" section for this.

http://sourceforge.net/projects/gnuwin32/files/file/5.03/

file-5.03-src.zip 1.2 MB 2009-05-07 1,664
file-5.03-src-setup.exe 764.0 KB 2009-05-07 931
file-5.03-setup.exe 835.3 KB 2009-05-07 12,096
file-5.03-lib.zip 7.1 KB 2009-05-07 1,721
file-5.03-doc.zip 191.2 KB 2009-05-07 1,021
file-5.03-dep.zip 84.7 KB 2009-05-07 1,624
file-5.03-bin.zip 442.6 KB 2009-05-07 5,672

Now, that looks like a lot of stuff to download. The package
undoubtedly includes some kind of installer, which will
add an entry to your PATH environment variable. But for
a simple test, all you need to do is as follows.

Put the following files in a folder. (Or, at least, these are the files
in my folder right now. Perhaps fewer files are necessary, but I won't
try that right now.) I expect these come from the bin and lib
downloads.

file.exe 45,056 bytes
magic1.dll 150,016 bytes
regex2.dll 79,360 bytes
zlib1.dll 72,192 bytes

Open a command prompt window, and change directory so you're pointed
to that folder of four files. You'll be executing the file.exe
command from within that folder.

Now, copy three sample text files into the folder.
I created three test files, and this is the result of the test.

file quick* > result.txt

result.txt:

quick.txt; ASCII text, with CRLF line terminators [0d 0a file]
quick1.txt; ASCII text, with CR line terminators [0d file]
quick2.txt; ASCII text [ 0a file]

So that file utility, allows a quick check of the type of text file.

I expect all you'd need to do, is stage those four files (and any
more packages you might like) into a single folder, add an extra
bit to the PATH environment variable, and then that "file" command
will be picked up when a script executes or the like.

If you mix all three types of line terminators in the same
file, the tool returns this. I have 0d0a, 0d, and 0a all
in the same file.

quick3.txt; ASCII text, with CRLF, CR, LF line terminators

What I haven't tested, is whether it reads the entire text file,
or only a portion of it.

HTH,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top