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 utf16-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'

Multiline Strings

A multiline string begins and ends with three single quotes (''').

Any quotes, tabs, or newlines in between the triple quotes are part of the string. While you can use the \ escape character inside a multiline string, escaping is not necessary (except for the \ character). The \ character at the end of a line in a multiline string removes the end of line and joins the two lines together.

Examples:

'Single\n quotes'; 
u'Can\'t be multiline and must escape embedded single quotes'; 
u8'€'; 
v'Can use various prefixes'; 
d'7172737475'; 
Q'ABCDE'; 

'''Triple 
quotes can have embedded newlines, but also \
support \n escape sequence'''; 
'''Single quotes inside a multiline string don't need escaping''';
u'''Unicode triple quotes 
should be the same, and also  \
support \n escape sequence'''; 
u'''Don't have to be multiline and need not escape embedded quotes (but \'can' if they want)'''; 
u8'''€'''; 
v'''Can use same prefixes as single'''; 
d'''7172737475'''; 
Q'''ABCDE''';