in reply to Re: [OT] Why does newline in Windows print as having width?
in thread [OT] Why does newline in Windows print as having width?
Hi Athanasius,
You wrote:
If you know that your command window will always be exactly 80 characters wide, you can get the output you want on Windows by simply omitting the newline character altogether:
The third section of the test program I posted does exactly that. Often I print things to both the console and a log file so it's annoying that they don't look the same if I try to print a partition across the whole line. Limiting my output to one less than the line width takes care of it but I was curious if other monks noticed or cared. I realize it's a very minor issue.
Update: I tried your one-liners with <STDIN>. That's a good demonstration of the issue. If someone wanted to print a full line of characters and then use \r or \b to overwrite characters they could in Linux but not in Windows. If I modify your one-liner for Windows like the following then I can overwrite characters but as soon as the last column is written to then the line advances.
perl -we "print q(-)x79,qq(\b\b);<STDIN>;"
Your demonstration shows the issue is that cmd.exe will advance as soon as the last column is printed to whereas Linux doesn't advance until one character past the last column. This shows it has nothing to do with one or two characters for '\n'.
|
---|