1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- G N A T . B Y T E _ O R D E R _ M A R K --
9 -- Copyright (C) 2006-2008, AdaCore --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
36 package body GNAT
.Byte_Order_Mark
is
46 XML_Support
: Boolean := False)
49 -- Note: the order of these tests is important, because in some cases
50 -- one sequence is a prefix of a longer sequence, and we must test for
51 -- the longer sequence first
53 -- UTF-32 (big-endian)
56 and then Str
(Str
'First) = Character'Val (16#
00#
)
57 and then Str
(Str
'First + 1) = Character'Val (16#
00#
)
58 and then Str
(Str
'First + 2) = Character'Val (16#FE#
)
59 and then Str
(Str
'First + 3) = Character'Val (16#FF#
)
64 -- UTF-32 (little-endian)
67 and then Str
(Str
'First) = Character'Val (16#FF#
)
68 and then Str
(Str
'First + 1) = Character'Val (16#FE#
)
69 and then Str
(Str
'First + 2) = Character'Val (16#
00#
)
70 and then Str
(Str
'First + 3) = Character'Val (16#
00#
)
75 -- UTF-16 (big-endian)
78 and then Str
(Str
'First) = Character'Val (16#FE#
)
79 and then Str
(Str
'First + 1) = Character'Val (16#FF#
)
84 -- UTF-16 (little-endian)
87 and then Str
(Str
'First) = Character'Val (16#FF#
)
88 and then Str
(Str
'First + 1) = Character'Val (16#FE#
)
93 -- UTF-8 (endian-independent)
96 and then Str
(Str
'First) = Character'Val (16#EF#
)
97 and then Str
(Str
'First + 1) = Character'Val (16#BB#
)
98 and then Str
(Str
'First + 2) = Character'Val (16#BF#
)
103 -- UCS-4 (big-endian) XML only
106 and then Str
'Length >= 4
107 and then Str
(Str
'First) = Character'Val (16#
00#
)
108 and then Str
(Str
'First + 1) = Character'Val (16#
00#
)
109 and then Str
(Str
'First + 2) = Character'Val (16#
00#
)
110 and then Str
(Str
'First + 3) = Character'Val (16#
3C#
)
115 -- UCS-4 (little-endian) XML case
118 and then Str
'Length >= 4
119 and then Str
(Str
'First) = Character'Val (16#
3C#
)
120 and then Str
(Str
'First + 1) = Character'Val (16#
00#
)
121 and then Str
(Str
'First + 2) = Character'Val (16#
00#
)
122 and then Str
(Str
'First + 3) = Character'Val (16#
00#
)
127 -- UCS-4 (unusual byte order 2143) XML case
130 and then Str
'Length >= 4
131 and then Str
(Str
'First) = Character'Val (16#
00#
)
132 and then Str
(Str
'First + 1) = Character'Val (16#
00#
)
133 and then Str
(Str
'First + 2) = Character'Val (16#
3C#
)
134 and then Str
(Str
'First + 3) = Character'Val (16#
00#
)
139 -- UCS-4 (unusual byte order 3412) XML case
142 and then Str
'Length >= 4
143 and then Str
(Str
'First) = Character'Val (16#
00#
)
144 and then Str
(Str
'First + 1) = Character'Val (16#
3C#
)
145 and then Str
(Str
'First + 2) = Character'Val (16#
00#
)
146 and then Str
(Str
'First + 3) = Character'Val (16#
00#
)
151 -- UTF-16 (big-endian) XML case
154 and then Str
'Length >= 4
155 and then Str
(Str
'First) = Character'Val (16#
00#
)
156 and then Str
(Str
'First + 1) = Character'Val (16#
3C#
)
157 and then Str
(Str
'First + 2) = Character'Val (16#
00#
)
158 and then Str
(Str
'First + 3) = Character'Val (16#
3F#
)
163 -- UTF-32 (little-endian) XML case
166 and then Str
'Length >= 4
167 and then Str
(Str
'First) = Character'Val (16#
3C#
)
168 and then Str
(Str
'First + 1) = Character'Val (16#
00#
)
169 and then Str
(Str
'First + 2) = Character'Val (16#
3F#
)
170 and then Str
(Str
'First + 3) = Character'Val (16#
00#
)
175 -- Unrecognized special encodings XML only
178 and then Str
'Length >= 4
179 and then Str
(Str
'First) = Character'Val (16#
3C#
)
180 and then Str
(Str
'First + 1) = Character'Val (16#
3F#
)
181 and then Str
(Str
'First + 2) = Character'Val (16#
78#
)
182 and then Str
(Str
'First + 3) = Character'Val (16#
6D#
)
184 -- UTF-8, ASCII, some part of ISO8859, Shift-JIS, EUC,...
197 end GNAT
.Byte_Order_Mark
;