Click to See Complete Forum and Search --> : Problem With Newlines


MrNewbie
02-23-2001, 01:56 PM
In perl I'm using printf and \n to print records into a file, but when I download the file back to windows to check it, instead of newlines I have weird box things or | sort of things, when I copy and paste these they are pasted as newlines and GVim sees them as newlines, wordpad sees them as newlines but Notepad shows them as those characters that are like a box and a pipe character, should I be worried about this or is it just wordpad being dumb?
MrNewbie

f'lar
02-23-2001, 02:07 PM
I think windows only uses one character for carriage return/line feed while linux uses two, so when you use a \n in a c++ program linux compilers will translate that into \10 and \13, or vice versa, or the operating system will do that when you display it. Anyway, that results in an extra unprintable character in windows. Smarter text editor in either system will know the difference, which is why wordpad looks okay.

MrNewbie
02-23-2001, 02:15 PM
pheew good thanks

kmj
02-23-2001, 02:15 PM
I think linux uses two and windows, one. If you edit a file in notepad, then ftp it to a *nix and open it in vim, it will have a "^M" at the end of each line.

f'lar
02-23-2001, 02:17 PM
Like I said: it might be the other way around. I haven't worried about it in a while. The net result is an extra charactar that gets seen differently by the each platform. Smarter editors should know what to do with it.

andrzej
02-23-2001, 03:24 PM
Linux:
LF (Line Feed) code: 0Ah

DOS/Windows:
CR LF (Carriage Return, Line Feed) codes: 0Dh 0Ah