Re: Backslash n [OT] was Line Separator and Paragraph Separator

From: jon@hackcraft.net
Date: Fri Oct 24 2003 - 03:21:06 CST


Quoting John Cowan <jcowan@reutershealth.com>:

> jon@hackcraft.net scripsit:
>
> > But if ('\n'=='\u000A') should always be true, because ISO 14882 defines \n
> as
> > LF and defines \uNNNN as "that character whose short name in ISO/IEC 10646
> is
> > 0000NNNN" and the character whose short name in ISO/IEC 10646 is 00000000A
> is
> > LF.
>
> It's not clear to me that this is true in C++. In C, it's definitely false,
> because character constants in C represent integers, and '\n' need not
> represent
> the integer 10, whereas '\u000A' must.

Well my thinking had been that given the definitions of \n and \u then \n would
have to equal \u000A but \x0A would not have to equal \u000A.

However, under closer examination we are both wrong. '\u000A' is not allowed!

From ISO/IEC 14882 (C++):
"If the hexadecimal value for a universal character name is less than 0x20 or
in the range 0x7F-0x9F (inclusive), or if the universal character name
designates a character in the basic source character set, then the program is
ill-formed."

From ISO/IEC 9899:1999 (C99):
"A universal character name shall not specify a character whose short
identifier is less than 00A0 other than 0024 ($), 0040 (@), or 0060 (), nor
one in the range D800 through DFFF inclusive"

And of course \u000A fails both of these constraints.

Still, I stand by saying that \n is defined in C++ as LF and \r as CR, because
that's sitting in front of me in black and white.

For completeness the definitions of \n and \r in C are:

"\n (new line) Moves the active position to the initial position of the next
line.
\r (carriage return) Moves the active position to the initial position of the
current line."

Whether that definition of \n matches the definition of LF is another matter.



This archive was generated by hypermail 2.1.5 : Thu Jan 18 2007 - 15:54:24 CST