User Tools

Site Tools


string_constants.htm
Navigation:  Language Reference > 10 - Expressions > Constants >====== String Constants ====== Previous pageReturn to chapter overviewNext page

A string constant is a set of characters enclosed in single quotes (apostrophes). The maximum length of a string constant is 255 characters. Characters that cannot be entered from the keyboard may be inserted into a string constant by enclosing their ASCII character codes in angle brackets (<;> ). ASCII character codes may be represented in decimal, hexadecimal, binary, or octal numeric constant format.

Unicode string constants have the leading 'U' or 'u' marker immediately before the opening apostrophe, for example:

U'Some многоязычный το κείμενο'

Unicode string literals can include the same { } and <;> meta-symbols as their ANSI equivalents. Numbers listed between <; and > meta-symbols are treated as 16-bit wide character codes. The C11 Clarion compiler supports source and include files in UTF-16 (little endian) and UTF-8 encoding to allow Unicode string literals without  the necessity to use explicit character codes inside the <;> meta-symbols.

In a string constant, a left angle bracket ( <; ) initiates a scan for a right angle bracket. Therefore, to include a left angle bracket in a string constant requires two left angle brackets in succession. To include an apostrophe as part of the value inside a string constant requires two apostrophes in succession. Two apostrophes ( ), with no characters (or just spaces) between them, represents a null, or blank, string. Consecutive occurrences of the same character within a string constant may be represented by repeat count notation. The number of times the character is to be repeated is placed within curly braces ( { } ) immediately following the character to repeat. To include a left curly brace ({) as part of the value inside a string constant requires two left curly braces ({{) in succession. The ampersand (&amp;) is always valid in a string constant. However, depending on the assignment's destination, it may be interpreted as an underscore for a hot letter (for example, a PROMPT control's display text). In this case, you double it up (&amp;&amp;) to end up with a single ampersand in the screen display. Example: 'string constant'   !A string constant 'Its a girl!'     !With embedded apostrophe '<;27,15>'           !Using decimal ASCII codes 'A <;<; B'            !With embedded left angle, A <; B '*{20}'             !Twenty asterisks, repeat-count notation                  !A null (blank) string

string_constants.htm.txt · Last modified: 2021/04/15 15:57 (external edit)