Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

escaping characters?

 [1/6] from: athiele:abraxis at: 10-Mar-2002 9:22


Hello, I`m new to Rebol and I have a simple question. I don`t seem to be able to find the answer to. How do you print quotes? I tried print ""hello"" print "\"hello\"" and others. Is there a way to escape characters like you do in C and other languages. Also newlines (\n) . Any input is appreciated. Adrian

 [2/6] from: gscottjones:mchsi at: 10-Mar-2002 8:54


From: "Adrian"
> Hello, > I`m new to Rebol and I have a simple question. I don`t seem to > be able to find the answer to. > How do you print quotes? I tried print ""hello"" print "\"hello\"" and > others. Is there a way to escape characters like you do in C and other > languages. Also newlines (\n) . Any input is appreciated.
Hi, Adrian, The "carrot" is the escape character and can be used like so:
>> print "^"Hello^""
Hello Or using curly braces negates the need to escape the double quotes:
>> print {"Hello"}
Hello Carrot slash (^/) is the return/newline sequence and it is translated correctly in each platform:
>> print {"Hello"^/"Goodbye"}
Hello Goodbye Hope that answers the questions. --Scott Jones

 [3/6] from: joel:neely:fedex at: 10-Mar-2002 9:34


Hi, Adrian, The escape for REBOL strings is the caret, not the backslash. In addition there are two ways to "bracket" strings: double-quote marks and curly braces. So either of the options below should take care of your need.
>> print {"hello"}
"hello"
>> print "^"hello^""
"hello" -jn- Adrian wrote:
> I`m new to Rebol and I have a simple question. I don`t seem to > be able to find the answer to. > How do you print quotes? I tried print ""hello"" print "\"hello\"" and > others. Is there a way to escape characters like you do in C and other > languages. Also newlines (\n) . Any input is appreciated. >
-- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;

 [4/6] from: athiele:abraxis at: 10-Mar-2002 12:53


Thanks for the quick response, I wanted to write a script to generate my index.r file so I thought I would need to print the quotes.

 [5/6] from: rebol665::ifrance::com at: 10-Mar-2002 19:58


Hi, Like C, Rebol has some "escape characters" such as #"^/" for newline. Each escape character is prefixed by a caret ^, so the first needed escape sequence is #"^^" to insert a real caret in a string. #"^^" to insert a caret in a string #"^"" to insert a double quote in a string The most usefull characters have a mnemonic notation. #"^(null) or "#"^@" for the null character #"^(tab)" or #"^-" for tabulation #"^(back)" or #"^H" for backspace #"^(line)" or #"^/" for newline #"^(page)" or #"^L" for newpage #"^(esc)" or #"^[" for escape #"^(del)" or #"^~" for delete With the same notation and hexadecimal values we can produce any character. #"^(00)" ... #"^(FF)" Patrick

 [6/6] from: chris:starforge:demon at: 11-Mar-2002 14:51


pat665 wrote:
> > With the same notation and hexadecimal values we can produce any character. > > #"^(00)" > ... > #"^(FF)"
That's a point - does REBOL have unicode support? Chris -- .------{ http://www.starforge.co.uk }-----. .--------------------------. =[ Explorer2260, Designer and Coder \=\ P: TexMaker, ROACH, site \ =[___You_will_obey_your_corporate_masters___]==[ Stack: EETmTmTRRSS------ ]