On 2008-09-27 19:47,
<> wrote:
> On Sep 27, 3:34*pm, Jürgen Exner <jurge...@hotmail.com> wrote:
>> "void.no.spam....@gmail.com" <void.no.spam....@gmail.com> wrote:
>> >I thought that on Windows, if you want to output a carriage return,
>> >you have to use \r\n instead of just \n.
>>
>> Neither nor. You are confusing two different layers.
>>
>> To output a carriage return you have to print the ASCII controll
>> character 13 (DEZ) or 0x0D (HEX) or short "\r". That is by definition
>> the CR character for ASCII which in turn is a subset of Windows-1252,
>> ISO-Latin-1, and many other encodings.
>>
>> "\n" on the other hand in Perl is a logical line end, which will be
>> translated automatically into the correct line end sequence for the
>> current OS, be it 0x0A for unixoide OSes, 0x0A 0x0D for Windows, or 0x0D
>> for Mac.
>>
>> So your combination \r\n on Windows will result in 0x0D 0X0A 0x0D.
>> Probably not what you want.
[...]
>
> Thanks for the explanation.
It is worth noting that the translation Jürgen talks about happens only
during file I/O. Inside of a perl script, "\n" is always a single
character ("\015" on old MacOS, "\012" on Unix, Windows, and (I think)
also on MacOS X). When writing to a file with the :crlf I/O layer enabled
(which is the default on Windows, but you can turn it off with binmode
or an argument to open), the single "\n" is converted to "\015\012". The
reverse conversion is done when reading a file with the :crlf layer.
(Perl can do other conversions on I/O, too, e.g., character set
conversions, compression, etc.)
hp