JRS: In article <opsialbslzx13kvk@atlantis>, dated Tue, 30 Nov 2004
19:17:58, seen in news:comp.lang.javascript, Michael Winter <M.Winter@bl
ueyonder.co.invalid> posted :
On 30 Nov 2004 10:45:41 -0800, RobB <fe******@hotmail.com> wrote:
[snip]
Wouldn't this do as well? ;)
var x = 'This string contains\
a new line';
No. It's invalid. Line terminators are not allowed to appear in any part
of a string literal. They *must* be escaped.
Yes, some browsers accept it, but (in my opinion) it should not be used as
you're relying on an unspecified extension to the language. Besides, if
you can change CR to \CR, why can't you replace CR with \n?
Moreover, on RobB's example, the newline is escaped out of existence,
not to a string-compatible version of itself. The string, in systems
(mot necessarily only browsers) that accept that backslash, is
This string containsa new line
so that it is a badly-composed falsehood!
BTW, AIUI, in javascript \n means newline; in different systems, that
might be CR = 13, LF = 10, CRLF, Unicode, ...
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.