String Literals

String literals consist of a sequence of zero or more ASCII characters or escape sequences surrounded by double quotation mark (").

String literals can be typed in multiple lines as shown here:

s="abc""def" \

"ghi"

which is same as s="abcdefhi".  '\' is the continuation character which allows.

If the 'L' suffix is added to the string literal, the result is a BString (Unicode). The conversion takes place after the ASCII string is scanned. Thus the \xhhh escape sequences can only represent 8 bits of data, not 16. Unicode characters which do not have a single byte ASCII representation need to be specified by a Multi-Byte Sequence as defined by Microsoft.

An escape sequence represents a single character (one byte), and can be any of the following:

 

Escape Sequence

Character Name

Value

\a

Bell

7

\b

Backspace

8

\f

Form feed

12

\n

Newline (Line feed)

10 or 0xa

\r

Carriage return

13 or 0xd

\t

Horizontal tab

9

\v

Vertical tab

11

\'

Single quotation mark

39 or 027

\"

Double quotation mark

34 or 022

\\

Backslash

92 or 05c

\xhhh

Hexadecimal number

\xhhh (i.e. "\x04A" same as "J"  or "\x00A same as "\n")

\c where c is any character not found above

Character or numeral

That character, for example, the letter c.

For more information on escape sequences, see Escape Sequences for Literals.

Syntax

"string" [optional suffix]

The syntax has the following parts:

 

Name

Type

Description

string

string constant

A sequence of zero or more ASCII characters or escape sequences surrounded by double quotation mark (").

suffix

suffix

The letter "L".

Comments

In ATEasy, the convention for naming string variables is to prefix the variable name with an 's' or 'bs', for example, sStringVar.

 Example

The following are two examples of string literals:

"First line\r\nSecond Line\r\n"

"Surrounded by carriage return and line feed\x00D\x00A"

See Also

Escape Sequences for Literals, Integer Literals