Constants

String

All string literals must be contained within single quotation marks ( ' ' ). All ECL code is UTF-8 encoded, which means that all strings are also UTF-8 encoded, whether Unicode or non-Unicode strings. Therefore, you must use a UTF-8 editor (such as the ECL IDE program).

To include the single quote character (apostrophe) in a constant string, prepend a backslash (\). To include the backslash character (\) in a constant string, use two backslashes (\\) together.

STRING20 MyString2 := 'Fred\'s Place';
                     //evaluated as: "Fred's Place"
STRING20 MyString3 := 'Fred\\Ginger\'s Place';
                    //evaluated as: "Fred\Ginger's Place"

Other available escape characters are:

\ttab
\nnew line
\rcarriage return
\nnn3 octal digits (for any other character)
\uhhhhlowercase "u" followed by 4 hexadecimal digits (for any other UNICODE-only character)
MyString1 := 'abcd'; 
MyString2 := U'abcd\353';    // becomes 'abcdë'

Hexadecimal string constants must begin with a leading "x" character. Only valid hexadecimal values (0-9, A-F) may be in the character string and there must be an even number of characters.

DATA2 MyHexString := x'0D0A'; // a 2-byte hexadecimal string

Data string constants must begin with a leading "D" character. This is directly equivalent to casting the string constant to DATA.

MyDataString := D'abcd'; // same as: (DATA)'abcd'

Unicode string constants must begin with a leading "U" character. Characters between the quotes are utf8-encoded and the type of the constant is UNICODE.

MyUnicodeString1 := U'abcd';        // same as: (UNICODE)'abcd'
MyUnicodeString2 := U'abcd\353';    // becomes 'abcdë'
MyUnicodeString3 := U'abcd\u00EB'; // becomes 'abcdë'«'

UTF8 string constants must begin with leading "U8" characters. Characters between the quotes are utf8-encoded and the type of the constant is UTF8.

MyUTF8String := U8'abcd\353';

VARSTRING string constants must begin with a leading "V" character. The terminating null byte is implied and type of the constant is VARSTRING.

MyVarString := V'abcd'; // same as: (VARSTRING)'abcd'

QSTRING string constants must begin with a leading "Q" character. The terminating null byte is implied and type of the constant is VARSTRING.

MyQString := Q'ABCD'; // same as: (QSTRING)'ABCD'