Sync with 5.4.0
[deliverable/titan.core.git] / help / info / octetstring.html
1 <!--
2 Copyright (c) 2000-2015 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>octetstring</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="oct2unichar.html"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="of.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>octetstring</h1>
33 <hr align="left" width="75%">
34 <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
35 non-negative integer.</p>
36 <ul>
37 <li>octet string values are written between <a href="#double_quotation"> single quotes and followed by the capital letter O.</a> (' 'O).</li>
38 <li>A octet string may be specified by its integer value using a <a href="#conversion">conversion function</a>.</li>
39 <li>The <a href="#relation">relational operators</a> equality (==) and non-equality (!=) can be used to compare values of two octet strings</li>
40 <li>The <a href="#shift">shift operators</a> perform the shift left (&lt;&lt;) and shift right (&gt;&gt;) operations.</li>
41 <li>The <a href="#rotate">rotate operators</a> perform the rotate left (&lt;@) and rotate right (@&gt;) operations.</li>
42 <li>The <a href="#concatenation"> concatenation operator</a> (&amp;) performs a simple concatenation from left to right.</li>
43 <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"
44 target="_blank">xor4b</a>) are used to manipulate bits in the string.</li>
45 <li>A <a href="#array"> single octet</a> may be accessed using an array-like syntax. The leftmost octet has the index zero.</li>
46 <li>The octet string may be <a href="#vacuum">empty</a>.</li>
47 <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>
48 <li>Another way to limit the permitted values of an octet string is <a href="#list">to list them</a>.</li>
49 <li>Predefined functions operating on octet strings:</li>
50 <ul>
51 <li><a href="#bit2hex">oct2hex</a> converts an octet string value to a hexadecimal string.</li>
52 <li><a href="#str2int">oct2int</a> converts an octet string to the equivalent integer.</li>
53 <li><a href="#str2oct">oct2bit</a> converts an octet string to a binary string.</li>
54 <li><a href="#bit2str">oct2str</a> displays an octet string as a character string.</li>
55 <li><a href="#oct2unichar">oct2unichar</a> converts an octet string as an universal character string.</li>
56 <li><a href="#unichar2oct">unichar2oct</a> converts an universal charcter string to an octet string.</li>
57 <li><a href="#lengthof">lengthof</a> returns an integer value indicating the number of octets in a string.</li>
58 <li><a href="#get_stringencoding">get_stringencoding</a> identifies the encoding of an octet string.</li>
59 <li><a href="#remove_bom">remove_bom</a> strips the BOM if it is present or returns the original octet string.</li>
60 </ul>
61 </ul>
62 <div align="center">
63 <center>
64 <table border="0" width="100%" bgcolor="#C9C2BB" cellpadding="4">
65 <tr>
66 <td width="100%">
67 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<u>TITAN specific extension to the standard:</u></p>
68 <ul>
69 <ul>
70 <li><a href="#oct2char">oct2char</a> converts an octet string to a character string.</li>
71 </ul>
72 </ul>
73 </td>
74 </tr>
75 </table>
76 </center>
77 </div>
78 <p>Related keywords:</p>
79 <ul>
80 <li><a href="bit2oct.html"><b><font face="Courier New" color="#003258" size="4">bit2oct</font></b></a></li>
81 <li><a href="char2oct.html"><b><font face="Courier New" color="#003258" size="4">char2oct</font></b></a></li>
82 <li><a href="hex2oct.html"><b><font face="Courier New" color="#003258" size="4">hex2oct</font></b></a></li>
83 <li><a href="int2oct.html"><b><font face="Courier New" color="#003258" size="4">int2oct</font></b></a></li>
84 <li><a href="length.html"><b><font face="Courier New" color="#003258" size="4">length</font></b></a></li>
85 <li><a href="lengthof.html"><b><font face="Courier New" color="#003258" size="4">lengthof</font></b></a></li>
86 <li><a href="oct2bit.html"><b><font face="Courier New" color="#003258" size="4">oct2bit</font></b></a></li>
87 <li><a href="oct2char.html"><b><font face="Courier New" color="#003258" size="4">oct2char</font></b></a></li>
88 <li><a href="oct2hex.html"><b><font face="Courier New" color="#003258" size="4">oct2hex</font></b></a></li>
89 <li><a href="oct2int.html"><b><font face="Courier New" color="#003258" size="4">oct2int</font></b></a></li>
90 <li><a href="oct2unichar.html"><b><font face="Courier New" color="#003258" size="4">oct2unichar</font></b></a></li>
91 <li><a href="unichar2oct.html"><b><font face="Courier New" color="#003258" size="4">unichar2oct</font></b></a></li>
92 <li><a href="oct2str.html"><b><font face="Courier New" color="#003258" size="4">oct2str</font></b></a></li>
93 <li><a href="get_stringencoding.html"><b><font face="Courier New" color="#003258" size="4">get_stringencoding</font></b></a></li>
94 <li><a href="remove_bom.html"><b><font face="Courier New" color="#003258" size="4">remove_bom</font></b></a></li>
95 <li><a href="str2oct.html"><b><font face="Courier New" color="#003258" size="4">str2oct</font></b></a></li>
96 <li><a href="substr.html"><b><font face="Courier New" color="#003258" size="4">substr</font></b></a></li>
97 <li><a href="and4b.html"><b><font face="Courier New" color="#003258" size="4">and4bit</font></b></a></li>
98 <li><a href="not4b.html"><b><font face="Courier New" color="#003258" size="4">not4bit</font></b></a></li>
99 <li><a href="or4b.html"><b><font face="Courier New" color="#003258" size="4">or4bit</font></b></a></li>
100 <li><a href="xor4b.html"><b><font face="Courier New" color="#003258" size="4">xor4bit</font></b></a></li>
101 </ul>
102 <hr align="left" width="50%">
103 <div align="center">
104 <center>
105 <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
106 <tr>
107 <td width="100%">
108 <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>octetstring</b></font></h3>
109 </td>
110 </tr>
111 </table>
112 </center>
113 </div>
114 <hr align="left" width="50%">
115 <p><a name="double_quotation">Example 1</a>:
116 <p><font face="Courier New">const octetstring c_ok := 'A5'O;<br>
117 </font>
118 <p>The constant defined is called c_ok and contains the octet string A5.</p>
119 <hr align="left" width="50%">
120 <p><a name="conversion">Example 2</a>:
121 <p><font face="Courier New">const octetstring c_entier := int2oct (266,2);<br>
122 </font>
123 <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>
124 <hr align="left" width="50%">
125 <p><a name="relation">Example 3</a>:
126 <p><font face="Courier New">const boolean c_niet := ( c_entier == c_ok );<br>
127 </font>
128 <p>The constant c_niet will have the value false, because two octet strings are not equal. The parentheses are optional.</p>
129 <hr align="left" width="50%">
130 <p><a name="concatenation">Example 4</a>:
131 <p><font face="Courier New">const octetstring c_clotre := c_entier &amp; c_ok;<br>
132 </font>
133 <p>The constant c_clotre will contain the octet string 010AA5&nbsp;</p>
134 <hr align="left" width="50%">
135 <p><a name="array">Example 5</a>:
136 <p><font face="Courier New">const octetstring c_samotny := c_entier[1];<br>
137 </font>
138 <p>The constant called c_samotny will contain the octet string 0A.</p>
139 <hr align="left" width="50%">
140 <p><a name="vacuum">Example 6</a>:
141 <p><font face="Courier New">const octetstring c_nil := ''O;<br>
142 </font>
143 <p>The constant called c_nil will be an empty string.</p>
144 <hr align="left" width="50%">
145 <p><a name="bit2hex">Example 7a</a>:
146 <p><font face="Courier New">const hexstring c_kungsen := oct2hex ('AA'O);</font><br>
147 <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
148 string).</p>
149 <hr align="left" width="50%">
150 <p><a name="str2int">Example 7b</a>:
151 <p><font face="Courier New">const integer c_prednost := oct2int ('55'O);<br>
152 </font>
153 <p>The constant called c_prednost will have the integer value 85. The result will be always positive.</p>
154 <hr align="left" width="50%">
155 <p><a name="str2oct">Example 7c</a>:
156 <p><font face="Courier New">const bitstring c_kvar := oct2bit ('44'O);<br>
157 </font>
158 <p>The constant called c_kvar will contain the bit string 01000100.</p>
159 <hr align="left" width="50%">
160 <p><a name="bit2str">Example 7d</a>:
161 <p><font face="Courier New">const charstring c_lettres := oct2str ('80FBBC0530A0'O);<br>
162 </font>
163 <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>
164 <hr align="left" width="50%">
165 <p><a name="lengthof">Example 7e</a>:
166 <p><font face="Courier New">const integer c_laenge := lengthof ('80FBBC0530A0'O);<br>
167 </font>
168 <p>The constant called c_laenge will have the value 6 corresponding to the number of octets in the string .</p>
169 <hr align="left" width="50%">
170 <p><a name="oct2char">Example 7f</a>:
171 <p><font face="Courier New">const charstring c_specific := oct2char (’4469707379’O);<br>
172 </font>
173 <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
174 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>
175 <hr align="left" width="50%">
176 <p><a name="list">Example 8</a>:
177 <p><font face="Courier New">var octetstring c_hinder ('1010'O,'77'O,'AA55CC'O );<br>
178 </font>
179 <p>The variable called c_hinder may hold the octet strings 1010, 77 and AA55CC only.</p>
180 <hr align="left" width="50%">
181 <p><a name="rotate">Example 9</a>:&nbsp;</p>
182 <p><font face="Courier New">const octetstring c_go_round := '1122334455'O &lt;@ (1+2);<br>
183 </font>
184 <p>The constant called c_go_round will hold the value '4455112233'O (the left operand rotated by three octets).</p>
185 <hr align="left" width="50%">
186 <p><a name="shift">Example 10</a>:</p>
187 <p><font face="Courier New">const octetstring c_slip := '1122334455'O &lt;&lt; (1+1);<br>
188 </font>
189 <p>The constant called c_slip will hold the value '3344550000'O (the left operand shifted by two octets) .</p>
190 <hr align="left" width="25%">
191 <hr align="left" width="25%">
192 <p align="left"><a HREF="BNF.html#bitstringkeyword">BNF definition</a> of <font face="Courier New">octetstring</font><br>
193 <a HREF="BNF.html#bitstringvalue">BNF definition</a> of octetstring value</p>
194 </body>
195 </html>
This page took 0.05408 seconds and 5 git commands to generate.