Debian Codegraph @

help/info/octetstring.html

raw symbols SCIP
1 <!--
2 Copyright (c) 2000-2021 Ericsson Telecom AB
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Eclipse Public License v2.0
5 which accompanies this distribution, and is available at
6 https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
7
8 Contributors:
9 Baji, Laszlo
10 Balasko, Jeno
11 Csorba, Mate
12 Farkas, Laszlo
13 Forstner, Matyas
14 Szabados, Kristof
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>octetstring</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="oct2unichar.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
33 <td><a href="of.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>octetstring</h1>
40 <hr align="left" width="75%">
41 <p>The keyword <b><font face="Courier New">octetstring</font></b> denotes a basic string type whose distinguished values are the ordered sequences of&nbsp; 2n hexadecimal digits where n is a
42 non-negative integer.</p>
43 <ul>
44 <li>octet string values are written between <a href="#double_quotation"> single quotes and followed by the capital letter O.</a> (' 'O).</li>
45 <li>A octet string may be specified by its integer value using a <a href="#conversion">conversion function</a>.</li>
46 <li>The <a href="#relation">relational operators</a> equality (==) and non-equality (!=) can be used to compare values of two octet strings</li>
47 <li>The <a href="#shift">shift operators</a> perform the shift left (&lt;&lt;) and shift right (&gt;&gt;) operations.</li>
48 <li>The <a href="#rotate">rotate operators</a> perform the rotate left (&lt;@) and rotate right (@&gt;) operations.</li>
49 <li>The <a href="#concatenation"> concatenation operator</a> (&amp;) performs a simple concatenation from left to right.</li>
50 <li>Bitwise operators (<a href="and4b.html">and4b</a>, <a href="not4b.html">not4b</a>, <a href="or4b.html">or4b</a>, <a href="xor4b.html"
51 target="_blank">xor4b</a>) are used to manipulate bits in the string.</li>
52 <li>A <a href="#array"> single octet</a> may be accessed using an array-like syntax. The leftmost octet has the index zero.</li>
53 <li>The octet string may be <a href="#vacuum">empty</a>.</li>
54 <li>The length of the octet 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>
55 <li>Another way to limit the permitted values of an octet string is <a href="#list">to list them</a>.</li>
56 <li>Predefined functions operating on octet strings:</li>
57 <ul>
58 <li><a href="#bit2hex">oct2hex</a> converts an octet string value to a hexadecimal string.</li>
59 <li><a href="#str2int">oct2int</a> converts an octet string to the equivalent integer.</li>
60 <li><a href="#str2oct">oct2bit</a> converts an octet string to a binary string.</li>
61 <li><a href="#bit2str">oct2str</a> displays an octet string as a character string.</li>
62 <li><a href="#oct2unichar">oct2unichar</a> converts an octet string as an universal character string.</li>
63 <li><a href="#unichar2oct">unichar2oct</a> converts an universal charcter string to an octet string.</li>
64 <li><a href="#lengthof">lengthof</a> returns an integer value indicating the number of octets in a string.</li>
65 <li><a href="#get_stringencoding">get_stringencoding</a> identifies the encoding of an octet string.</li>
66 <li><a href="#remove_bom">remove_bom</a> strips the BOM if it is present or returns the original octet string.</li>
67 </ul>
68 </ul>
69 <div align="center">
70 <center>
71 <table border="0" width="100%" bgcolor="#C9C2BB" cellpadding="4">
72 <tr>
73 <td width="100%">
74 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<u>TITAN specific extension to the standard:</u></p>
75 <ul>
76 <ul>
77 <li><a href="#oct2char">oct2char</a> converts an octet string to a character string.</li>
78 </ul>
79 </ul>
80 </td>
81 </tr>
82 </table>
83 </center>
84 </div>
85 <p>Related keywords:</p>
86 <ul>
87 <li><a href="bit2oct.html"><b><font face="Courier New" color="#003258" size="4">bit2oct</font></b></a></li>
88 <li><a href="char2oct.html"><b><font face="Courier New" color="#003258" size="4">char2oct</font></b></a></li>
89 <li><a href="hex2oct.html"><b><font face="Courier New" color="#003258" size="4">hex2oct</font></b></a></li>
90 <li><a href="int2oct.html"><b><font face="Courier New" color="#003258" size="4">int2oct</font></b></a></li>
91 <li><a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a></li>
92 <li><a href="lengthof.html"><b><font face="Courier New" color="#003258" size="4">lengthof</font></b></a></li>
93 <li><a href="oct2bit.html"><b><font face="Courier New" color="#003258" size="4">oct2bit</font></b></a></li>
94 <li><a href="oct2char.html"><b><font face="Courier New" color="#003258" size="4">oct2char</font></b></a></li>
95 <li><a href="oct2hex.html"><b><font face="Courier New" color="#003258" size="4">oct2hex</font></b></a></li>
96 <li><a href="oct2int.html"><b><font face="Courier New" color="#003258" size="4">oct2int</font></b></a></li>
97 <li><a href="oct2unichar.html"><b><font face="Courier New" color="#003258" size="4">oct2unichar</font></b></a></li>
98 <li><a href="unichar2oct.html"><b><font face="Courier New" color="#003258" size="4">unichar2oct</font></b></a></li>
99 <li><a href="oct2str.html"><b><font face="Courier New" color="#003258" size="4">oct2str</font></b></a></li>
100 <li><a href="get_stringencoding.html"><b><font face="Courier New" color="#003258" size="4">get_stringencoding</font></b></a></li>
101 <li><a href="remove_bom.html"><b><font face="Courier New" color="#003258" size="4">remove_bom</font></b></a></li>
102 <li><a href="str2oct.html"><b><font face="Courier New" color="#003258" size="4">str2oct</font></b></a></li>
103 <li><a href="substr.html"><b><font face="Courier New" color="#003258" size="4">substr</font></b></a></li>
104 <li><a href="and4b.html"><b><font face="Courier New" color="#003258" size="4">and4bit</font></b></a></li>
105 <li><a href="not4b.html"><b><font face="Courier New" color="#003258" size="4">not4bit</font></b></a></li>
106 <li><a href="or4b.html"><b><font face="Courier New" color="#003258" size="4">or4bit</font></b></a></li>
107 <li><a href="xor4b.html"><b><font face="Courier New" color="#003258" size="4">xor4bit</font></b></a></li>
108 </ul>
109 <hr align="left" width="50%">
110 <div align="center">
111 <center>
112 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
113 <tr>
114 <td width="100%">
115 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>octetstring</b></font></h3>
116 </td>
117 </tr>
118 </table>
119 </center>
120 </div>
121 <hr align="left" width="50%">
122 <p><a name="double_quotation">Example 1</a>:
123 <p><font face="Courier New">const octetstring c_ok := 'A5'O;<br>
124 </font>
125 <p>The constant defined is called c_ok and contains the octet string A5.</p>
126 <hr align="left" width="50%">
127 <p><a name="conversion">Example 2</a>:
128 <p><font face="Courier New">const octetstring c_entier := int2oct (266,2);<br>
129 </font>
130 <p>The constant c_entier will contain the octet string 010A because the converted integer number (127 -&gt; 10A) must be coded on 2 octets and therefore padded with a leading zero.</p>
131 <hr align="left" width="50%">
132 <p><a name="relation">Example 3</a>:
133 <p><font face="Courier New">const boolean c_niet := ( c_entier == c_ok );<br>
134 </font>
135 <p>The constant c_niet will have the value false, because two octet strings are not equal. The parentheses are optional.</p>
136 <hr align="left" width="50%">
137 <p><a name="concatenation">Example 4</a>:
138 <p><font face="Courier New">const octetstring c_clotre := c_entier &amp; c_ok;<br>
139 </font>
140 <p>The constant c_clotre will contain the octet string 010AA5&nbsp;</p>
141 <hr align="left" width="50%">
142 <p><a name="array">Example 5</a>:
143 <p><font face="Courier New">const octetstring c_samotny := c_entier[1];<br>
144 </font>
145 <p>The constant called c_samotny will contain the octet string 0A.</p>
146 <hr align="left" width="50%">
147 <p><a name="vacuum">Example 6</a>:
148 <p><font face="Courier New">const octetstring c_nil := ''O;<br>
149 </font>
150 <p>The constant called c_nil will be an empty string.</p>
151 <hr align="left" width="50%">
152 <p><a name="bit2hex">Example 7a</a>:
153 <p><font face="Courier New">const hexstring c_kungsen := oct2hex ('AA'O);</font><br>
154 <p>The constant called c_kungsen will have the hexadecimal value AA. Although&nbsp;both values on the screen may look the same (AA), they have different types (octet string respective character
155 string).</p>
156 <hr align="left" width="50%">
157 <p><a name="str2int">Example 7b</a>:
158 <p><font face="Courier New">const integer c_prednost := oct2int ('55'O);<br>
159 </font>
160 <p>The constant called c_prednost will have the integer value 85. The result will be always positive.</p>
161 <hr align="left" width="50%">
162 <p><a name="str2oct">Example 7c</a>:
163 <p><font face="Courier New">const bitstring c_kvar := oct2bit ('44'O);<br>
164 </font>
165 <p>The constant called c_kvar will contain the bit string 01000100.</p>
166 <hr align="left" width="50%">
167 <p><a name="bit2str">Example 7d</a>:
168 <p><font face="Courier New">const charstring c_lettres := oct2str ('80FBBC0530A0'O);<br>
169 </font>
170 <p>The constant called c_lettres will contain the string 80FBBC0530A0 because the resulting character string has the double length as the octet string and contains only the characters '0' .. 'F'.</p>
171 <hr align="left" width="50%">
172 <p><a name="lengthof">Example 7e</a>:
173 <p><font face="Courier New">const integer c_laenge := lengthof ('80FBBC0530A0'O);<br>
174 </font>
175 <p>The constant called c_laenge will have the value 6 corresponding to the number of octets in the string .</p>
176 <hr align="left" width="50%">
177 <p><a name="oct2char">Example 7f</a>:
178 <p><font face="Courier New">const charstring c_specific := oct2char (’4469707379’O);<br>
179 </font>
180 <p>The constant called c_specific will contain the string &quot;Dipsy&quot; because the resulting character string will have the same length as the incoming octet string. The octets are
181 interpreted as ISO/IEC 646 [8] codes (according to the IRV) and the resulting characters are stored in the returned string. Octet values higher than 7F cause an error.</p>
182 <hr align="left" width="50%">
183 <p><a name="list">Example 8</a>:
184 <p><font face="Courier New">var octetstring c_hinder ('1010'O,'77'O,'AA55CC'O );<br>
185 </font>
186 <p>The variable called c_hinder may hold the octet strings 1010, 77 and AA55CC only.</p>
187 <hr align="left" width="50%">
188 <p><a name="rotate">Example 9</a>:&nbsp;</p>
189 <p><font face="Courier New">const octetstring c_go_round := '1122334455'O &lt;@ (1+2);<br>
190 </font>
191 <p>The constant called c_go_round will hold the value '4455112233'O (the left operand rotated by three octets).</p>
192 <hr align="left" width="50%">
193 <p><a name="shift">Example 10</a>:</p>
194 <p><font face="Courier New">const octetstring c_slip := '1122334455'O &lt;&lt; (1+1);<br>
195 </font>
196 <p>The constant called c_slip will hold the value '3344550000'O (the left operand shifted by two octets) .</p>
197 <hr align="left" width="25%">
198 <hr align="left" width="25%">
199 <p align="left"><a HREF="BNF.html#bitstringkeyword">BNF definition</a> of <font face="Courier New">octetstring</font><br>
200 <a HREF="BNF.html#bitstringvalue">BNF definition</a> of octetstring value</p>
201 </body>
202 </html>