Windows CRLF vs Linux LF

Hellbovine

Active Member
A shower thought I had today...

This is a general non-NTLite question, but also has an NTLite element too:

For all you coders out there, when I was working with LPC I had to learn to convert all my code files into Linux LF in my Notepad++ rather than using the default Windows CRLF, or else in rare scenarios it can cause issues...

1) Well, now I'm curious about the Windows OS itself. Should my .bat and .reg files for example all use the Windows CRLF when I run them from the desktop? I know maybe that sounds silly to ask, like "do you use windows on windows" but it's not that far fetched, since Linux is a major component of a lot of things out in the world that not everyone may realize. For all I know Microsoft has Linux aspects in Windows too. I'm not a programmer! :p

2) Does NTLite care what I use? A lot of programs, even programs written for Windows still abide by some basic Linux principles due to their compilers or whatever tech speak. So does NTLite care if the .reg files I import for example are CRLF versus LF? And then this plays into the final question...

3) Also in LPC I had to end all of my files with a newline (EOL), for the same kind of reasons explained above, sometimes you can get oddball errors if you don't do this... Does the Windows OS have similar issues with things like .bat and .reg files if you don't put the EOL? And what about NTLite, is it possible that if you don't have the EOL on these kinds of files when you import them into NTLite that it could potentially cause an oddball error?
 
Last edited:

Hellbovine

Active Member
So I searched the forum after I posted this and did find a reply by Garlin regarding NTLite and xml unattend and this issue did pop up! So I'm curious to hear more elaboration on this topic if anyone knows more:


Thanks!
 

garlin

Moderator
Staff member
Most Windows programs are oblivious to character encoding & CRLF style. The notable exception being Registry 5.00 files.
The rule of thumb is if it looks wrong in Notepad, some app won't like it.

My default working environment is Cygwin on Windows. I prefer the Unix POSIX regular expression tools, because Windows parsing just sucks.
This means I'm having to switch encoding all the time (dos2unix, unix2dos). But vim is smart enough to match the original file's format.

Registry 4 files are ANSI (think "ASCII").

Registry 5 files are Unicode (supports int'l languages). Technically it's UTF-16, little-ended with BOM (byte order marker). There's a big difference when you open a reg file EXPORTED by regedit, vs creating a new one by hand.

If you're editing a file created by another app, your editor should save it back in the original format. But if you're making one up from scratch, pay attention. Your regedit/reg command inside a BAT script might reject the file. PowerShell can also be picky.
 

Hellbovine

Active Member
Oh very interesting. I had a mix of .reg files, some of them were UTF-16 LE because I exported them from regedit, then kept adding more to the file, but some others I had just used Windows Notepad to save as a .reg extension and those default as UTF-8. I didn't experience any issues so far, but I'm OCD about this kind of stuff so I'm going to fix them all now lol.
 
Top