| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
<html> |
| 17 |
<head> |
| 18 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 19 |
<meta http-equiv="Content-Language" content="en-us"> |
| 20 |
<title>charstring</title> |
| 21 |
</head> |
| 22 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 23 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 24 |
<tr> |
| 25 |
<td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td> |
| 26 |
</tr> |
| 27 |
</table> |
| 28 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 29 |
<tr> |
| 30 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 31 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 32 |
<td><a alt="previous" href="char2oct.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 33 |
<td><a href="check.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 34 |
</tr> |
| 35 |
</table> |
| 36 |
<p><br clear="all"> |
| 37 |
</p> |
| 38 |
<hr> |
| 39 |
<h1>charstring</h1> |
| 40 |
<hr align="left" width="75%"> |
| 41 |
<p>The keyword <b><font face="Courier New"> charstring</font></b> denotes a basic string type whose distinguished values are the ordered sequences of characters of <a |
| 42 |
href="http://en.wikipedia.org/wiki/ISO_646" target="_blank">ISO/IEC 646</a> International Reference Version (IRV) - formerly International Alphabet No.5 (IA5) described in ITU-T Recommendation T.50.</p> |
| 43 |
<ul> |
| 44 |
<li>Character string values are written between <a href="#double_quotation"> double quotes</a> (" ").</li> |
| 45 |
<li>A single character may be specified by its decimal code point using a <a href="#conversion">conversion function</a>.</li> |
| 46 |
<li>A <a href="#quotation_inside"> double quote inside character string</a> is represented by a pair of double quotes with no intervening space.</li> |
| 47 |
<li>The <a href="#relation">relational operators</a> equality (==) and non-equality (!=) can be used to compare values of two character strings</li> |
| 48 |
<li>The <a href="#rotate">rotate operators</a> perform the rotate left (<@) and rotate right (@>) operations.</li> |
| 49 |
<li>The <a href="#concatenation"> concatenation operator</a> (&) performs a simple concatenation from left to right.</li> |
| 50 |
<li>A <a href="#array"> single character</a> may be accessed using an array-like syntax. The leftmost character has the index zero.</li> |
| 51 |
<li>The character string may be <a href="#vacuum">empty</a>.</li> |
| 52 |
<li>Predefined functions operating on character strings:</li> |
| 53 |
<ul> |
| 54 |
<li><a href="#char2int">char2int</a> converts a single character into an integer value in the range of 1 ⦠127 corresponding to code point of the character.</li> |
| 55 |
<li><a href="#str2float">str2float</a> converts a character string representing an floating point value to the equivalent float value.</li> |
| 56 |
<li><a href="#str2int">str2int</a> converts a character string representing an integer value to the equivalent integer.</li> |
| 57 |
<li><a href="#str2oct">str2oct</a> converts a character string value to an octet string.</li> |
| 58 |
<li><a href="#lengthof">lengthof</a> returns an integer value indicating the number of characters in a string.</li> |
| 59 |
</ul> |
| 60 |
</ul> |
| 61 |
<table border="0" width="100%" bgcolor="#C9C2BB" cellpadding="4"> |
| 62 |
<tr> |
| 63 |
<td width="100%"> |
| 64 |
<p> <u>TITAN specific extensions to the standard:</u></p> |
| 65 |
<ul> |
| 66 |
<ul> |
| 67 |
<li><a href="#oct2char">char2oct</a> converts a character string value to an octet string.</li> |
| 68 |
<li><a href="#str2bit">str2bit</a> converts a character string value to a bit string, where each character represents the value of one bit in the resulting bit string.</li> |
| 69 |
<li><a href="#str2hex">str2hex</a> converts a character string value to a hexadecimal string.</li> |
| 70 |
</ul> |
| 71 |
</ul> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
</table> |
| 75 |
<ul> |
| 76 |
<li>The length of the character string can be constrained using the keyword <a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a>.</li> |
| 77 |
<li>The <a href="#range">range of the permitted characters</a> may be specified.</li> |
| 78 |
<li>Another way to limit the permitted values of a character string is <a href="#list">to list them</a>.</li> |
| 79 |
</ul> |
| 80 |
<p>Related keywords:</p> |
| 81 |
<ul> |
| 82 |
<li><a href="bit2str.html"><b><font face="Courier New" color="#003258" size="4">bit2str</font></b></a></li> |
| 83 |
<li><a href="char2int.html"><b><font face="Courier New" color="#003258" size="4">char2int</font></b></a></li> |
| 84 |
<li><a href="char2oct.html"><b><font face="Courier New" color="#003258" size="4">char2oct</font></b></a></li> |
| 85 |
<li><a href="float2str.html"><b><font face="Courier New" color="#003258" size="4">float2str</font></b></a></li> |
| 86 |
<li><a href="hex2str.html"><b><font face="Courier New" color="#003258" size="4">hex2str</font></b></a></li> |
| 87 |
<li><a href="int2char.html"><b><font face="Courier New" color="#003258" size="4">int2char</font></b></a></li> |
| 88 |
<li><a href="int2str.html"><b><font face="Courier New" color="#003258" size="4">int2str</font></b></a></li> |
| 89 |
<li><a href="int2unichar.html"><b><font face="Courier New" color="#003258" size="4">int2unichar</font></b></a></li> |
| 90 |
<li><a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a></li> |
| 91 |
<li><a href="lengthof.html"><b><font face="Courier New" color="#003258" size="4">lengthof</font></b></a></li> |
| 92 |
<li><a href="oct2char.html"><b><font face="Courier New" color="#003258" size="4">oct2char</font></b></a></li> |
| 93 |
<li><a href="oct2str.html"><b><font face="Courier New" color="#003258" size="4">oct2str</font></b></a></li> |
| 94 |
<li><a href="regexp.html"><b><font face="Courier New" color="#003258" size="4">regexp</font></b></a></li> |
| 95 |
<li><a href="str2bit.html"><b><font face="Courier New" color="#003258" size="4">str2bit</font></b></a></li> |
| 96 |
<li><a href="str2float.html"><b><font face="Courier New" color="#003258" size="4">str2float</font></b></a></li> |
| 97 |
<li><a href="str2hex.html"><b><font face="Courier New" color="#003258" size="4">str2hex</font></b></a></li> |
| 98 |
<li><a href="str2int.html"><b><font face="Courier New" color="#003258" size="4">str2int</font></b></a></li> |
| 99 |
<li><a href="str2oct.html"><b><font face="Courier New" color="#003258" size="4">str2oct</font></b></a></li> |
| 100 |
<li><a href="substr.html"><b><font face="Courier New" color="#003258" size="4">substr</font></b></a></li> |
| 101 |
<li><a href="unichar2int.html"><b><font face="Courier New" color="#003258" size="4">unichar2int</font></b></a></li> |
| 102 |
<li><a href="universal.html"><b><font face="Courier New" color="#003258" size="4">universal</font></b></a></li> |
| 103 |
</ul> |
| 104 |
<hr align="left" width="50%"> |
| 105 |
<div align="center"> |
| 106 |
<center> |
| 107 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 108 |
<tr> |
| 109 |
<td width="100%"> |
| 110 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>charstring</b></font></h3> |
| 111 |
</td> |
| 112 |
</tr> |
| 113 |
</table> |
| 114 |
</center> |
| 115 |
</div> |
| 116 |
<hr align="left" width="50%"> |
| 117 |
<p><a name="double_quotation">Example 1</a>: |
| 118 |
<p><font face="Courier New">const charstring c_fuezeer := "AazZ";<br> |
| 119 |
</font> |
| 120 |
<p>The constant defined is called c_fuezeer and has the value AazZ.</p> |
| 121 |
<hr align="left" width="50%"> |
| 122 |
<p><a name="conversion">Example 1a</a>: |
| 123 |
<p><font face="Courier New">const charstring c_veve := int2char (119);<br> |
| 124 |
</font> |
| 125 |
<p>The constant called c_veve will contain the letter w</p> |
| 126 |
<hr align="left" width="50%"> |
| 127 |
<p><a name="quotation_inside">Example 2</a>: |
| 128 |
<p><font face="Courier New">const charstring c_ideezoe := "Citationstecken:""";<br> |
| 129 |
</font> |
| 130 |
<p>The constant defined is called c_ideezo and has the value Citationstecken:".</p> |
| 131 |
<hr align="left" width="50%"> |
| 132 |
<p><a name="relation">Example 3</a>: |
| 133 |
<p><font face="Courier New">const boolean c_saluton := ( c_fuezeer == c_ideezoe );<br> |
| 134 |
</font> |
| 135 |
<p>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 |
| 136 |
are optional.</p> |
| 137 |
<hr align="left" width="50%"> |
| 138 |
<p><a name="concatenation">Example 4</a>: |
| 139 |
<p><font face="Courier New">const charstring c_lepidlo := c_fuezeer & c_ideezoe;<br> |
| 140 |
</font> |
| 141 |
<p>The constant c_lepidlo will have the value AazZCitationstecken:".</p> |
| 142 |
<hr align="left" width="50%"> |
| 143 |
<p><a name="array">Example 5</a>: |
| 144 |
<p><font face="Courier New">const charstring c_elem := c_fuezeer[2];<br> |
| 145 |
</font> |
| 146 |
<p>The constant called c_elem will consist of of a single element with the value z.</p> |
| 147 |
<hr align="left" width="50%"> |
| 148 |
<p><a name="vacuum">Example 6</a>: |
| 149 |
<p><font face="Courier New">const charstring c_vacuum := "";<br> |
| 150 |
</font> |
| 151 |
<p>The constant called c_vacuum will be an empty string.</p> |
| 152 |
<hr align="left" width="50%"> |
| 153 |
<p><a name="char2int">Example 7a</a>: |
| 154 |
<p><font face="Courier New">const integer c_siffra := char2int ("@");<br> |
| 155 |
</font> |
| 156 |
<p>The constant called c_siffror will have the integer value 64.</p> |
| 157 |
<hr align="left" width="50%"> |
| 158 |
<p><a name="str2float">Example 7b</a>: |
| 159 |
<p><font face="Courier New">const integer c_ziffer := str2float ("+123.456E+02");<br> |
| 160 |
</font> |
| 161 |
<p>The constant called c_ziffer will have the floating point value 12345.6.</p> |
| 162 |
<hr align="left" width="50%"> |
| 163 |
<p><a name="str2int">Example 7c</a>: |
| 164 |
<p><font face="Courier New">const integer c_siffra := str2int ("-66");<br> |
| 165 |
</font> |
| 166 |
<p>The constant called c_siffra will have the integer value -66.</p> |
| 167 |
<hr align="left" width="50%"> |
| 168 |
<p><a name="str2oct">Example 7d</a>: |
| 169 |
<p><font face="Courier New">const octetstring c_duebel := str2oct ("Tinky-Winky");<br> |
| 170 |
</font> |
| 171 |
<p>The constant called c_duebel will have the value '54696E6B792D57696E6B79'O .</p> |
| 172 |
<hr align="left" width="50%"> |
| 173 |
<p><a name="lengthof">Example 7e</a>: |
| 174 |
<p><font face="Courier New">const integer c_longeco := lengthof ("pentristino");<br> |
| 175 |
</font> |
| 176 |
<p>The constant called c_longeco will have the value 11 corresponding to the number of characters in the string .</p> |
| 177 |
<hr align="left" width="50%"> |
| 178 |
<p><a name="oct2char">Example 7f</a>: |
| 179 |
<p><font face="Courier New">const octetstring c_deposed := char2oct ("Tinky-Winky"); <br> |
| 180 |
</font> |
| 181 |
<p>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 |
| 182 |
of the octet string will contain the ASCII codes of the appropriate characters of the character string.</p> |
| 183 |
<hr align="left" width="50%"> |
| 184 |
<p><a name="str2bit">Example 7g</a></p> |
| 185 |
<p><font face="Courier New">const bitstring c_marque := str2bit ("1011011100");<br> |
| 186 |
</font> |
| 187 |
<p>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 |
| 188 |
characters ’0’ or ’1’ only, otherwise the result is a dynamic test case error.</p> |
| 189 |
<hr align="left" width="50%"> |
| 190 |
<p><a name="str2hex">Example 7h</a></p> |
| 191 |
<p><font face="Courier New">const hexstring c_jesien := str2hex ("1D7"); <br> |
| 192 |
</font> |
| 193 |
<p>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 |
| 194 |
hexadecimal string in the same order.</p> |
| 195 |
<hr align="left" width="50%"> |
| 196 |
<p><a name="list">Example 8</a>: |
| 197 |
<p><font face="Courier New">var charstring v_schranke ("F", "f");<br> |
| 198 |
</font> |
| 199 |
<p>The variable called v_schranke may hold the characters "F" and "f" only .</p> |
| 200 |
<hr align="left" width="50%"> |
| 201 |
<p><a name="rotate">Example 9</a>: </p> |
| 202 |
<p><font face="Courier New">const charstring c_ringlspiel := "abcdefg" <@ 3;<br> |
| 203 |
</font> |
| 204 |
<p>The constant called c_ringlspiel will hold the value"defgabc" (the left operand rotated by three characters). </p> |
| 205 |
<hr align="left" width="50%"> |
| 206 |
<p><a name="range">Example 10</a>: |
| 207 |
<p><font face="Courier New">var charstring v_span ("c" .. "e");<br> |
| 208 |
</font> |
| 209 |
<p>The variable v_span may have the following values: "c", "d", "e".</p> |
| 210 |
<hr align="left" width="25%"> |
| 211 |
<hr align="left" width="25%"> |
| 212 |
<p align="left"><a HREF="BNF.html#charstringkeyword">BNF definition</a> of <font face="Courier New">charstring</font><br> |
| 213 |
<a HREF="BNF.html#cstring">BNF definition</a> of charstring value</p> |
| 214 |
</body> |
| 215 |
</html> |