Logiweb(TM)

7.1.5.2 String escapes

Prev Up Next Page 138 of 800 Search internet


Inside strings, a number of escape sequences may be used to denote special characters:

""- No character
"". End of string
""! Double quote
""f Form feed
""n Line feed
""r Carriage return
""t Horizontal tab
""x Characters given in hexadecimal (until period)

Recall that, by convention, text in Logiweb is represented in Logiweb Unicode UTF-8 in which lines are separated by line feeds (code 10) and all special characters (codes in the interval 0..31) are illegal. Sometimes, however, there are good reasons for using other conventions.

lgc(1) converts host newline sequences to line feeds when reading an lgs source file and has facilities to converting the other way when emitting text files. Furthermore, lgc converts form feeds to line feeds, converts horizontal tabs to spaces, and protests if it sees any other special character. For that reason, line feed (code 10) is the only special character which can directly enter a string.

Occasionally, however, one may need strings which contain form feeds, horizontal tabs, or arbitrary bytes. Most of the string escape sequences allow to enter characters into strings which one cannot enter otherwise.

The ""! escape sequence allows to include a double quote character in a string. The ""f, ""r, and ""t escape sequences allow to include a form feed, a carriage return, and a horizontal tab, respectively. The ""n escape sequence can be used as an alternative for a line feed character.

The ""- and "". escape sequences were treated in the previous section.

The ""x escape sequence allows to enter an arbitrary number of arbitrary bytes into a string. They bytes have to be expressed in mixed endian hexadecimal and have to be followed by a terminating period. As an example,

  "ab""636465.fg"

denotes the string 'abcdefg'. In mixed endian hexadecimal, each byte is expressed with the most significant hex digit first and the bytes are stated in the order they appear in the string.

Prev Up Next Page 138 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05