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