Re: Non-Printable Characters in Strings

Gavin Lambert <[email protected]> Tue, 10 Feb 2004 09:01:52 +1300
Newsgroups gmane.comp.lang.moo.general
Organization Mirality Systems
Message-ID <5.1.1.6.0.20040210085800.0208d978@localhost>
At 00:51 28/01/2004 +0000, Luke-Jr wrote:
 >
 >How should non-printable characters be represented in strings?
 >Is C-style escaping of common characters (\n, \r, \t, \v, \x##,
 >etc) a good idea? Including C-style's \### which uses octal or
 >should \### use decimal (or hex?)?

I've always regarded C-style escaping as a little messy... but 
then, that's mostly because I need to use the backslash a lot for 
paths and the like.

One possible alternative (though I don't really know if it's any 
better) is to use Delphi-style escaping, a la:
   "This is a string with"#10"a newline in the middle."
   "This is a string with "" a double-quote in the middle."
   "This is a string that " +
     "spans two source lines."

Of course, the latter example is already valid in MOO code, but of 
course the internal compiler/decompiler will merge it back onto 
one source line.

-- 
Gavin Lambert, Mirality Systems
<http://www.mirality.co.nz/>
----
Pardon me, waiter. I like my water diluted.



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn