On Oct 11, 2008, at 6:15 AM, Aristotle Pagaltzis wrote:

* Smylers <smyl...@stripey.com> [2008-10-10 19:40]:
Which characters?  The representation \r denotes a carriage
return, aka character \x0D.

Whereas \n denotes a 'new line', a virtual concept which is
made up of some concept of some combination of line feeds
(\x0A) and carriage returns, in an attempt to cope with the
hateful different ways OSes have denoted line breaks.

Also, on MacOS Classic `\n` means `\x0d` instead, and is the same
as `\r`. This is true for C programs on that platform as well.

Depends on the compiler. In MPW, \r gets you \x0a. I think this is true of MacPerl as well.

However, this is an application issue. The MacRoman character encoding maps CR to \x0d and LF to \x0a. The text-handling parts of the OS use CR for newline, and Apple's MPW compilers swap \r and \n compared to normal use, but that just means it's not POSIX. MPW's shell also uses '∂' (little delta) instead of '\', but that doesn't imply the former has a code point of \x5c.

Incidentally, Lamp's shell, perl, and compiler all treat \r and \n as in Unix. This depends on the interpreter, not the OS.

But `\n` always means *exactly one character* which on ASCII
systems is always `\x0a`.

[citation needed]

#!/usr/bin/perl

foreach ( @ARGV )
{
        s{ [\] n }{ \r }gx;
        
        print;
}

If you run this on your system, does it become non-ASCII?

Josh


Reply via email to