blob: 8518749476dbaeacb9ff4c72fc83035fb7952937 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001CONCEPT
2 character escape codes
3
4DESCRIPTION
5 Character escape codes are used to represent some common
6 special characters that would be awkward or impossible to
7 enter in the source program directly. The escape characters
8 come in two varieties: 'character escapes', which can be
9 used to represent some particular formatting and special
10 characters, and 'numeric escapes', which allow a character to
11 be specified by its numeric encoding.
12
13 Escapes begin always with a backslash '\'. If the following
14 characters could not be treated as a valid escape the backslash
15 is merely ignored.
16
17 The following character escapes are available in LPC (the code
18 may differ from platform to platform):
19
20 \a Code 007 Bell
21 \b Code 008 Backspace
22 \e Code 027 Escape
23 \f Code 012 Formfeed
24 \n Code 010 Newline
25 \r Code 013 Carriage-Return
26 \t Code 009 Tabulator
27 \\ Code 092 Backslash itself
28 \' Code 039 Single quote
29 \" Code 034 Double quote
30
31 The single quote may appear without preceding backslash in character
32 constants, and the double quote may appear without a backslash in
33 string constants.
34
35 The numeric escapes could be used to express a character directly
36 by its code in binary, octal, decimal or hexadecimal notation.
37
38 \0b Beginning of binary notation
39 \0o Beginning of octal notation
40 \0x Beginning of hexadecimal notation
41 \x Beginning of hexadecimal notation
42
43 A backslash followed by a digit ([0-9]) which does not map to one
44 of the above starts an escape in decimal notation.
45
46 A numeric escape terminates when N digits have been used up or
47 when the first character that is not a valid digit in that
48 notation is encountered. N is 2 for hexadeximals, 3 for
49 decimals and octals and 8 for binarys.
50
51 If the specified code is greater than 255 a warning is issued and
52 the value modulo 256 is used.
53
54EXAMPLES
55 Put a newline at the end of user output
56 "You enter.\n"
57
58 Alert the user
59 "Beeep.\a Wake up\n"
60
61 Put a double quote in a string
62 "You say \"hello\"\n"
63
64 Write the line from above
65 "\"You say \\\"hello\\\"\\n\""
66
67 Put a single quote in a string
68 "You say 'hello'\n"
69
70 Some forms to write "abcde"
71 "abcde"
72 "ab\99de" (with c's code being 99)
73 "ab\099de"
74 "ab\x63de" (99 = 0x63)
75 "ab\0x63de"
76
77 The following string consists of two characters
78 "\0111" (\011 and 1)
79
80 The following string consists of three characters
81 "\0o090" (\000 and 9 and 0)