# charstring

The keyword charstring denotes a basic string type whose distinguished values are the ordered sequences of characters of ISO/IEC 646 International Reference Version (IRV) - formerly International Alphabet No.5 (IA5) described in ITU-T Recommendation T.50.

- Character string values are written between double quotes (" ").
- A single character may be specified by its decimal code point using a conversion function.
- A double quote inside character string is represented by a pair of double quotes with no intervening space.
- The relational operators equality (==) and non-equality (!=) can be used to compare values of two character strings
- The rotate operators perform the rotate left (<@) and rotate right (@>) operations.
- The concatenation operator (&) performs a simple concatenation from left to right.
- A single character may be accessed using an array-like syntax. The leftmost character has the index zero.
- The character string may be empty.
- Predefined functions operating on character strings:

- char2int converts a single character into an integer value in the range of 1 â¦ 127 corresponding to code point of the character.
- str2float converts a character string representing an floating point value to the equivalent float value.
- str2int converts a character string representing an integer value to the equivalent integer.
- str2oct converts a character string value to an octet string.
- lengthof returns an integer value indicating the number of characters in a string.

TITAN specific extensions to the standard:

- char2oct converts a character string value to an octet string.
- str2bit converts a character string value to a bit string, where each character represents the value of one bit in the resulting bit string.
- str2hex converts a character string value to a hexadecimal string.

- The length of the character string can be constrained using the keyword length.
- The range of the permitted characters may be specified.
- Another way to limit the permitted values of a character string is to list them.

Related keywords:

- bit2str
- char2int
- char2oct
- float2str
- hex2str
- int2char
- int2str
- int2unichar
- length
- lengthof
- oct2char
- oct2str
- regexp
- str2bit
- str2float
- str2hex
- str2int
- str2oct
- substr
- unichar2int
- universal

### charstring

Example 1:

const charstring c_fuezeer := "AazZ";

The constant defined is called c_fuezeer and has the value AazZ.

Example 1a:

const charstring c_veve := int2char (119);

The constant called c_veve will contain the letter w

Example 2:

const charstring c_ideezoe := "Citationstecken:""";

The constant defined is called c_ideezo and has the value Citationstecken:".

Example 3:

const boolean c_saluton := ( c_fuezeer == c_ideezoe );

The constant c_saluton will have the value false, because two character strings are equal only if they have equal lengths and the characters at all positions are the same. The parantheses are optional.

Example 4:

const charstring c_lepidlo := c_fuezeer & c_ideezoe;

The constant c_lepidlo will have the value AazZCitationstecken:".

Example 5:

const charstring c_elem := c_fuezeer[2];

The constant called c_elem will consist of of a single element with the value z.

Example 6:

const charstring c_vacuum := "";

The constant called c_vacuum will be an empty string.

Example 7a:

const integer c_siffra := char2int ("@");

The constant called c_siffror will have the integer value 64.

Example 7b:

const integer c_ziffer := str2float ("+123.456E+02");

The constant called c_ziffer will have the floating point value 12345.6.

Example 7c:

const integer c_siffra := str2int ("-66");

The constant called c_siffra will have the integer value -66.

Example 7d:

const octetstring c_duebel := str2oct ("Tinky-Winky");

The constant called c_duebel will have the value '54696E6B792D57696E6B79'O .

Example 7e:

const integer c_longeco := lengthof ("pentristino");

The constant called c_longeco will have the value 11 corresponding to the number of characters in the string .

Example 7f:

const octetstring c_deposed := char2oct ("Tinky-Winky");

The constant called c_deposed will contain the octet string ’54696E6B792D57696E6B79’O because the resulting octet string will have the same length as the incoming character string. The octets of the octet string will contain the ASCII codes of the appropriate characters of the character string.

Example 7g

const bitstring c_marque := str2bit ("1011011100");

The constant called c_marque will contain the bit string ’1011011100’B because each character represents the value of one bit in the resulting bit string. Its argument may contain the characters ’0’ or ’1’ only, otherwise the result is a dynamic test case error.

Example 7h

const hexstring c_jesien := str2hex ("1D7");

The constant called c_jesien will contain the hexadecimal string ’1D7’H because each character in the character string represents the value of one hexadecimal digit in the resulting hexadecimal string in the same order.

Example 8:

var charstring v_schranke ("F", "f");

The variable called v_schranke may hold the characters "F" and "f" only .

Example 9:

const charstring c_ringlspiel := "abcdefg" <@ 3;

The constant called c_ringlspiel will hold the value"defgabc" (the left operand rotated by three characters).

Example 10:

var charstring v_span ("c" .. "e");

The variable v_span may have the following values: "c", "d", "e".

BNF definition of charstring
BNF definition of charstring value