in reply to automatic endlines when saving txt file under windows?

Hi emilford,

I work with a data interchange language called HL7, which normally isn't that bad except when some brain-dead integration code drops odd characters into it. Not to deride wordpad and notepad for the fine products they are (hey, they work exactly as advertised!) but other tools may help you make sure what you think you have in the file is really what you have.

For example in one troubled message we received that was causing our engine to puke the bad record it looked normal in emacs but in gvim what looked like a pipe was actually something else. It looked like a control character in gvim and in command mode typing 'ga' with the cursor on the character give it's ascii and octal values. I'm not knocking emacs here since other tools can produce odd results when faced with unexpected data (like wc -l in dealing with mixed \r and \n).

Anyway my long winded point is that you need something that can tell you what you really have in the files. Obviously changing their extension doesn't change the content (unless windows is dumber than I thought) so there is some kind of file type interpolation going on. I recommend using gvim for windows (and every other OS {G} - and while I'm p1mp1ng it, vim has great Perl syntax highlighting - http://vim.sf.net/ ) where if you type ':%!xxd' from the command mode will convert the file into hex and you can see exactly what the file contains. Any other hex editor or tools like xxd or od -c will do the trick as well. (Oh, and in gvim ':%!xxd -r' will convert back to plain ascii. Obviously the single quotes should not be used in typing any of the vim commands.)

Sadly a coder is only as good as their tools, but with Perl on our side we are already fairly excellent. ;)

Good luck,
{NULE}
--
http://www.nule.org

P.S. One more thing, (I honestly didn't intend to turn this post into 'The VIM Show™') but if your files are supposed to be identical you can use VIM to diff them by calling 'gvimdiff file1 file2' or 'gvim -d file1 file2'.

  • Comment on Re: automatic endlines when saving txt file under windows?