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-2007, 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 ------------------------------------------------------------------------------
34 package body GNAT.Byte_Order_Mark is
44 XML_Support : Boolean := False)
47 -- UTF-16 (big-endian)
50 and then Str (Str'First) = Character'Val (16#FE#)
51 and then Str (Str'First + 1) = Character'Val (16#FF#)
56 -- UTF-16 (little-endian)
59 and then Str (Str'First) = Character'Val (16#FF#)
60 and then Str (Str'First + 1) = Character'Val (16#FE#)
65 -- UTF-32 (big-endian)
68 and then Str (Str'First) = Character'Val (16#00#)
69 and then Str (Str'First + 1) = Character'Val (16#00#)
70 and then Str (Str'First + 2) = Character'Val (16#FE#)
71 and then Str (Str'First + 3) = Character'Val (16#FF#)
76 -- UTF-32 (little-endian)
79 and then Str (Str'First) = Character'Val (16#FF#)
80 and then Str (Str'First + 1) = Character'Val (16#FE#)
81 and then Str (Str'First + 2) = Character'Val (16#00#)
82 and then Str (Str'First + 3) = Character'Val (16#00#)
87 -- UTF-8 (endian-independent)
90 and then Str (Str'First) = Character'Val (16#EF#)
91 and then Str (Str'First + 1) = Character'Val (16#BB#)
92 and then Str (Str'First + 2) = Character'Val (16#BF#)
97 -- UCS-4 (big-endian) XML only
100 and then Str'Length >= 4
101 and then Str (Str'First) = Character'Val (16#00#)
102 and then Str (Str'First + 1) = Character'Val (16#00#)
103 and then Str (Str'First + 2) = Character'Val (16#00#)
104 and then Str (Str'First + 3) = Character'Val (16#3C#)
109 -- UCS-4 (little-endian) XML case
112 and then Str'Length >= 4
113 and then Str (Str'First) = Character'Val (16#3C#)
114 and then Str (Str'First + 1) = Character'Val (16#00#)
115 and then Str (Str'First + 2) = Character'Val (16#00#)
116 and then Str (Str'First + 3) = Character'Val (16#00#)
121 -- UCS-4 (unusual byte order 2143) XML case
124 and then Str'Length >= 4
125 and then Str (Str'First) = Character'Val (16#00#)
126 and then Str (Str'First + 1) = Character'Val (16#00#)
127 and then Str (Str'First + 2) = Character'Val (16#3C#)
128 and then Str (Str'First + 3) = Character'Val (16#00#)
133 -- UCS-4 (unusual byte order 3412) XML case
136 and then Str'Length >= 4
137 and then Str (Str'First) = Character'Val (16#00#)
138 and then Str (Str'First + 1) = Character'Val (16#3C#)
139 and then Str (Str'First + 2) = Character'Val (16#00#)
140 and then Str (Str'First + 3) = Character'Val (16#00#)
145 -- UTF-16 (big-endian) XML case
148 and then Str'Length >= 4
149 and then Str (Str'First) = Character'Val (16#00#)
150 and then Str (Str'First + 1) = Character'Val (16#3C#)
151 and then Str (Str'First + 2) = Character'Val (16#00#)
152 and then Str (Str'First + 3) = Character'Val (16#3F#)
157 -- UTF-32 (little-endian) XML case
160 and then Str'Length >= 4
161 and then Str (Str'First) = Character'Val (16#3C#)
162 and then Str (Str'First + 1) = Character'Val (16#00#)
163 and then Str (Str'First + 2) = Character'Val (16#3F#)
164 and then Str (Str'First + 3) = Character'Val (16#00#)
169 -- Unrecognized special encodings XML only
172 and then Str'Length >= 4
173 and then Str (Str'First) = Character'Val (16#3C#)
174 and then Str (Str'First + 1) = Character'Val (16#3F#)
175 and then Str (Str'First + 2) = Character'Val (16#78#)
176 and then Str (Str'First + 3) = Character'Val (16#6D#)
178 -- Utf8, ASCII, some part of ISO8859, Shift-JIS, EUC,...
191 end GNAT.Byte_Order_Mark;