File: unicode-ccs-windows_1252.adb

package info (click to toggle)
libxmlada 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,212 kB
  • sloc: ada: 78,068; sh: 3,310; makefile: 394; xml: 111; python: 39
file content (331 lines) | stat: -rw-r--r-- 19,205 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
------------------------------------------------------------------------------
--                     XML/Ada - An XML suite for Ada95                     --
--                                                                          --
--                     Copyright (C) 2005-2017, AdaCore                     --
--                                                                          --
-- This library is free software;  you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software  Foundation;  either version 3,  or (at your  option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------

with Ada.Exceptions; use Ada.Exceptions;
with Unicode.Names.Latin_Extended_A; use Unicode.Names.Latin_Extended_A;
with Unicode.Names.Latin_Extended_B; use Unicode.Names.Latin_Extended_B;
with Unicode.Names.Latin_1_Supplement; use Unicode.Names.Latin_1_Supplement;
with Unicode.Names.Spacing_Modifier_Letters;
use Unicode.Names.Spacing_Modifier_Letters;
with Unicode.Names.Currency_Symbols; use Unicode.Names.Currency_Symbols;
with Unicode.Names.General_Punctuation;
use Unicode.Names.General_Punctuation;
with Unicode.Names.Letterlike_Symbols;
use Unicode.Names.Letterlike_Symbols;

package body Unicode.CCS.Windows_1252 is

   Undefined : constant Unicode_Char := 16#0000#;

   To_Unicode_Arr : constant array (Unicode_Char range <>) of Unicode_Char :=
     (16#0080# => Euro_Sign,
      16#0081# => Undefined,
      16#0082# => Single_Low_9_Quotation_Mark,
      16#0083# => Latin_Small_Letter_F_With_Hook,
      16#0084# => Double_Low_9_Quotation_Mark,
      16#0085# => Horizontal_Ellipsis,
      16#0086# => Dagger,
      16#0087# => Double_Dagger,
      16#0088# => Modifier_Letter_Circumflex_Accent,
      16#0089# => Per_Mille_Sign,
      16#008A# => Latin_Capital_Letter_S_With_Caron,
      16#008B# => Single_Left_Pointing_Angle_Quotation_Mark,
      16#008C# => Latin_Capital_Ligature_Oe,
      16#008D# => Undefined,
      16#008E# => Latin_Capital_Letter_Z_With_Caron,
      16#008F# => Undefined,
      16#0090# => Undefined,
      16#0091# => Left_Single_Quotation_Mark,
      16#0092# => Right_Single_Quotation_Mark,
      16#0093# => Left_Double_Quotation_Mark,
      16#0094# => Right_Double_Quotation_Mark,
      16#0095# => Bullet,
      16#0096# => En_Dash,
      16#0097# => Em_Dash,
      16#0098# => Small_Tilde,
      16#0099# => Trade_Mark_Sign,
      16#009A# => Latin_Small_Letter_S_With_Caron,
      16#009B# => Single_Right_Pointing_Angle_Quotation_Mark,
      16#009C# => Latin_Small_Ligature_Oe,
      16#009D# => Undefined,
      16#009E# => Latin_Small_Letter_Z_With_Caron,
      16#009F# => Latin_Capital_Letter_Y_With_Diaeresis,
      16#00A0# => No_Break_Space,
      16#00A1# => Inverted_Exclamation_Mark,
      16#00A2# => Cent_Sign,
      16#00A3# => Pound_Sign,
      16#00A4# => Currency_Sign,
      16#00A5# => Yen_Sign,
      16#00A6# => Broken_Bar,
      16#00A7# => Section_Sign,
      16#00A8# => Diaeresis,
      16#00A9# => Copyright_Sign,
      16#00AA# => Feminine_Ordinal_Indicator,
      16#00AB# => Left_Pointing_Double_Angle_Quotation_Mark,
      16#00AC# => Not_Sign,
      16#00AD# => Soft_Hyphen,
      16#00AE# => Registered_Sign,
      16#00AF# => Macron,
      16#00B0# => Degree_Sign,
      16#00B1# => Plus_Minus_Sign,
      16#00B2# => Superscript_Two,
      16#00B3# => Superscript_Three,
      16#00B4# => Acute_Accent,
      16#00B5# => Micro_Sign,
      16#00B6# => Pilcrow_Sign,
      16#00B7# => Middle_Dot,
      16#00B8# => Cedilla,
      16#00B9# => Superscript_One,
      16#00BA# => Masculine_Ordinal_Indicator,
      16#00BB# => Right_Pointing_Double_Angle_Quotation_Mark,
      16#00BC# => Vulgar_Fraction_One_Quarter,
      16#00BD# => Vulgar_Fraction_One_Half,
      16#00BE# => Vulgar_Fraction_Three_Quarters,
      16#00BF# => Inverted_Question_Mark,
      16#00C0# => Latin_Capital_Letter_A_With_Grave,
      16#00C1# => Latin_Capital_Letter_A_With_Acute,
      16#00C2# => Latin_Capital_Letter_A_With_Circumflex,
      16#00C3# => Latin_Capital_Letter_A_With_Tilde,
      16#00C4# => Latin_Capital_Letter_A_With_Diaeresis,
      16#00C5# => Latin_Capital_Letter_A_With_Ring_Above,
      16#00C6# => Latin_Capital_Letter_Ae,
      16#00C7# => Latin_Capital_Letter_C_With_Cedilla,
      16#00C8# => Latin_Capital_Letter_E_With_Grave,
      16#00C9# => Latin_Capital_Letter_E_With_Acute,
      16#00CA# => Latin_Capital_Letter_E_With_Circumflex,
      16#00CB# => Latin_Capital_Letter_E_With_Diaeresis,
      16#00CC# => Latin_Capital_Letter_I_With_Grave,
      16#00CD# => Latin_Capital_Letter_I_With_Acute,
      16#00CE# => Latin_Capital_Letter_I_With_Circumflex,
      16#00CF# => Latin_Capital_Letter_I_With_Diaeresis,
      16#00D0# => Latin_Capital_Letter_Eth,
      16#00D1# => Latin_Capital_Letter_N_With_Tilde,
      16#00D2# => Latin_Capital_Letter_O_With_Grave,
      16#00D3# => Latin_Capital_Letter_O_With_Acute,
      16#00D4# => Latin_Capital_Letter_O_With_Circumflex,
      16#00D5# => Latin_Capital_Letter_O_With_Tilde,
      16#00D6# => Latin_Capital_Letter_O_With_Diaeresis,
      16#00D7# => Multiplication_Sign,
      16#00D8# => Latin_Capital_Letter_O_With_Stroke,
      16#00D9# => Latin_Capital_Letter_U_With_Grave,
      16#00DA# => Latin_Capital_Letter_U_With_Acute,
      16#00DB# => Latin_Capital_Letter_U_With_Circumflex,
      16#00DC# => Latin_Capital_Letter_U_With_Diaeresis,
      16#00DD# => Latin_Capital_Letter_Y_With_Acute,
      16#00DE# => Latin_Capital_Letter_Thorn,
      16#00DF# => Latin_Small_Letter_Sharp_S,
      16#00E0# => Latin_Small_Letter_A_With_Grave,
      16#00E1# => Latin_Small_Letter_A_With_Acute,
      16#00E2# => Latin_Small_Letter_A_With_Circumflex,
      16#00E3# => Latin_Small_Letter_A_With_Tilde,
      16#00E4# => Latin_Small_Letter_A_With_Diaeresis,
      16#00E5# => Latin_Small_Letter_A_With_Ring_Above,
      16#00E6# => Latin_Small_Letter_Ae,
      16#00E7# => Latin_Small_Letter_C_With_Cedilla,
      16#00E8# => Latin_Small_Letter_E_With_Grave,
      16#00E9# => Latin_Small_Letter_E_With_Acute,
      16#00EA# => Latin_Small_Letter_E_With_Circumflex,
      16#00EB# => Latin_Small_Letter_E_With_Diaeresis,
      16#00EC# => Latin_Small_Letter_I_With_Grave,
      16#00ED# => Latin_Small_Letter_I_With_Acute,
      16#00EE# => Latin_Small_Letter_I_With_Circumflex,
      16#00EF# => Latin_Small_Letter_I_With_Diaeresis,
      16#00F0# => Latin_Small_Letter_Eth,
      16#00F1# => Latin_Small_Letter_N_With_Tilde,
      16#00F2# => Latin_Small_Letter_O_With_Grave,
      16#00F3# => Latin_Small_Letter_O_With_Acute,
      16#00F4# => Latin_Small_Letter_O_With_Circumflex,
      16#00F5# => Latin_Small_Letter_O_With_Tilde,
      16#00F6# => Latin_Small_Letter_O_With_Diaeresis,
      16#00F7# => Division_Sign,
      16#00F8# => Latin_Small_Letter_O_With_Stroke,
      16#00F9# => Latin_Small_Letter_U_With_Grave,
      16#00FA# => Latin_Small_Letter_U_With_Acute,
      16#00FB# => Latin_Small_Letter_U_With_Circumflex,
      16#00FC# => Latin_Small_Letter_U_With_Diaeresis,
      16#00FD# => Latin_Small_Letter_Y_With_Acute,
      16#00FE# => Latin_Small_Letter_Thorn,
      16#00FF# => Latin_Small_Letter_Y_With_Diaeresis);

   ----------------
   -- To_Unicode --
   ----------------

   function To_Unicode (Char : Unicode_Char) return Unicode_Char is
   begin
      if Char > To_Unicode_Arr'Last then
         Raise_Exception
           (Invalid_Code'Identity,
            "code " & Unicode_Char'Image (Char)
            & " is not available in Windows-1252");
      elsif Char < To_Unicode_Arr'First then
         return Char;

      else
         return To_Unicode_Arr (Char);
      end if;
   end To_Unicode;

   ---------------------
   -- To_Windows_1252 --
   ---------------------

   function To_Windows_1252 (Char : Unicode_Char) return Unicode_Char is
   begin
      if Char < To_Unicode_Arr'First then
         return Char;
      else
         case Char is
            when Euro_Sign                                  => return 16#0080#;
            when Single_Low_9_Quotation_Mark                => return 16#0082#;
            when Latin_Small_Letter_F_With_Hook             => return 16#0083#;
            when Double_Low_9_Quotation_Mark                => return 16#0084#;
            when Horizontal_Ellipsis                        => return 16#0085#;
            when Dagger                                     => return 16#0086#;
            when Double_Dagger                              => return 16#0087#;
            when Modifier_Letter_Circumflex_Accent          => return 16#0088#;
            when Per_Mille_Sign                             => return 16#0089#;
            when Latin_Capital_Letter_S_With_Caron          => return 16#008A#;
            when Single_Left_Pointing_Angle_Quotation_Mark  => return 16#008B#;
            when Latin_Capital_Ligature_Oe                  => return 16#008C#;
            when Latin_Capital_Letter_Z_With_Caron          => return 16#008E#;
            when Left_Single_Quotation_Mark                 => return 16#0091#;
            when Right_Single_Quotation_Mark                => return 16#0092#;
            when Left_Double_Quotation_Mark                 => return 16#0093#;
            when Right_Double_Quotation_Mark                => return 16#0094#;
            when Bullet                                     => return 16#0095#;
            when En_Dash                                    => return 16#0096#;
            when Em_Dash                                    => return 16#0097#;
            when Small_Tilde                                => return 16#0098#;
            when Trade_Mark_Sign                            => return 16#0099#;
            when Latin_Small_Letter_S_With_Caron            => return 16#009A#;
            when Single_Right_Pointing_Angle_Quotation_Mark => return 16#009B#;
            when Latin_Small_Ligature_Oe                    => return 16#009C#;
            when Latin_Small_Letter_Z_With_Caron            => return 16#009E#;
            when Latin_Capital_Letter_Y_With_Diaeresis      => return 16#009F#;
            when No_Break_Space                             => return 16#00A0#;
            when Inverted_Exclamation_Mark                  => return 16#00A1#;
            when Cent_Sign                                  => return 16#00A2#;
            when Pound_Sign                                 => return 16#00A3#;
            when Currency_Sign                              => return 16#00A4#;
            when Yen_Sign                                   => return 16#00A5#;
            when Broken_Bar                                 => return 16#00A6#;
            when Section_Sign                               => return 16#00A7#;
            when Diaeresis                                  => return 16#00A8#;
            when Copyright_Sign                             => return 16#00A9#;
            when Feminine_Ordinal_Indicator                 => return 16#00AA#;
            when Left_Pointing_Double_Angle_Quotation_Mark  => return 16#00AB#;
            when Not_Sign                                   => return 16#00AC#;
            when Soft_Hyphen                                => return 16#00AD#;
            when Registered_Sign                            => return 16#00AE#;
            when Macron                                     => return 16#00AF#;
            when Degree_Sign                                => return 16#00B0#;
            when Plus_Minus_Sign                            => return 16#00B1#;
            when Superscript_Two                            => return 16#00B2#;
            when Superscript_Three                          => return 16#00B3#;
            when Acute_Accent                               => return 16#00B4#;
            when Micro_Sign                                 => return 16#00B5#;
            when Pilcrow_Sign                               => return 16#00B6#;
            when Middle_Dot                                 => return 16#00B7#;
            when Cedilla                                    => return 16#00B8#;
            when Superscript_One                            => return 16#00B9#;
            when Masculine_Ordinal_Indicator                => return 16#00BA#;
            when Right_Pointing_Double_Angle_Quotation_Mark => return 16#00BB#;
            when Vulgar_Fraction_One_Quarter                => return 16#00BC#;
            when Vulgar_Fraction_One_Half                   => return 16#00BD#;
            when Vulgar_Fraction_Three_Quarters             => return 16#00BE#;
            when Inverted_Question_Mark                     => return 16#00BF#;
            when Latin_Capital_Letter_A_With_Grave          => return 16#00C0#;
            when Latin_Capital_Letter_A_With_Acute          => return 16#00C1#;
            when Latin_Capital_Letter_A_With_Circumflex     => return 16#00C2#;
            when Latin_Capital_Letter_A_With_Tilde          => return 16#00C3#;
            when Latin_Capital_Letter_A_With_Diaeresis      => return 16#00C4#;
            when Latin_Capital_Letter_A_With_Ring_Above     => return 16#00C5#;
            when Latin_Capital_Letter_Ae                    => return 16#00C6#;
            when Latin_Capital_Letter_C_With_Cedilla        => return 16#00C7#;
            when Latin_Capital_Letter_E_With_Grave          => return 16#00C8#;
            when Latin_Capital_Letter_E_With_Acute          => return 16#00C9#;
            when Latin_Capital_Letter_E_With_Circumflex     => return 16#00CA#;
            when Latin_Capital_Letter_E_With_Diaeresis      => return 16#00CB#;
            when Latin_Capital_Letter_I_With_Grave          => return 16#00CC#;
            when Latin_Capital_Letter_I_With_Acute          => return 16#00CD#;
            when Latin_Capital_Letter_I_With_Circumflex     => return 16#00CE#;
            when Latin_Capital_Letter_I_With_Diaeresis      => return 16#00CF#;
            when Latin_Capital_Letter_Eth                   => return 16#00D0#;
            when Latin_Capital_Letter_N_With_Tilde          => return 16#00D1#;
            when Latin_Capital_Letter_O_With_Grave          => return 16#00D2#;
            when Latin_Capital_Letter_O_With_Acute          => return 16#00D3#;
            when Latin_Capital_Letter_O_With_Circumflex     => return 16#00D4#;
            when Latin_Capital_Letter_O_With_Tilde          => return 16#00D5#;
            when Latin_Capital_Letter_O_With_Diaeresis      => return 16#00D6#;
            when Multiplication_Sign                        => return 16#00D7#;
            when Latin_Capital_Letter_O_With_Stroke         => return 16#00D8#;
            when Latin_Capital_Letter_U_With_Grave          => return 16#00D9#;
            when Latin_Capital_Letter_U_With_Acute          => return 16#00DA#;
            when Latin_Capital_Letter_U_With_Circumflex     => return 16#00DB#;
            when Latin_Capital_Letter_U_With_Diaeresis      => return 16#00DC#;
            when Latin_Capital_Letter_Y_With_Acute          => return 16#00DD#;
            when Latin_Capital_Letter_Thorn                 => return 16#00DE#;
            when Latin_Small_Letter_Sharp_S                 => return 16#00DF#;
            when Latin_Small_Letter_A_With_Grave            => return 16#00E0#;
            when Latin_Small_Letter_A_With_Acute            => return 16#00E1#;
            when Latin_Small_Letter_A_With_Circumflex       => return 16#00E2#;
            when Latin_Small_Letter_A_With_Tilde            => return 16#00E3#;
            when Latin_Small_Letter_A_With_Diaeresis        => return 16#00E4#;
            when Latin_Small_Letter_A_With_Ring_Above       => return 16#00E5#;
            when Latin_Small_Letter_Ae                      => return 16#00E6#;
            when Latin_Small_Letter_C_With_Cedilla          => return 16#00E7#;
            when Latin_Small_Letter_E_With_Grave            => return 16#00E8#;
            when Latin_Small_Letter_E_With_Acute            => return 16#00E9#;
            when Latin_Small_Letter_E_With_Circumflex       => return 16#00EA#;
            when Latin_Small_Letter_E_With_Diaeresis        => return 16#00EB#;
            when Latin_Small_Letter_I_With_Grave            => return 16#00EC#;
            when Latin_Small_Letter_I_With_Acute            => return 16#00ED#;
            when Latin_Small_Letter_I_With_Circumflex       => return 16#00EE#;
            when Latin_Small_Letter_I_With_Diaeresis        => return 16#00EF#;
            when Latin_Small_Letter_Eth                     => return 16#00F0#;
            when Latin_Small_Letter_N_With_Tilde            => return 16#00F1#;
            when Latin_Small_Letter_O_With_Grave            => return 16#00F2#;
            when Latin_Small_Letter_O_With_Acute            => return 16#00F3#;
            when Latin_Small_Letter_O_With_Circumflex       => return 16#00F4#;
            when Latin_Small_Letter_O_With_Tilde            => return 16#00F5#;
            when Latin_Small_Letter_O_With_Diaeresis        => return 16#00F6#;
            when Division_Sign                              => return 16#00F7#;
            when Latin_Small_Letter_O_With_Stroke           => return 16#00F8#;
            when Latin_Small_Letter_U_With_Grave            => return 16#00F9#;
            when Latin_Small_Letter_U_With_Acute            => return 16#00FA#;
            when Latin_Small_Letter_U_With_Circumflex       => return 16#00FB#;
            when Latin_Small_Letter_U_With_Diaeresis        => return 16#00FC#;
            when Latin_Small_Letter_Y_With_Acute            => return 16#00FD#;
            when Latin_Small_Letter_Thorn                   => return 16#00FE#;
            when Latin_Small_Letter_Y_With_Diaeresis        => return 16#00FF#;
            when others =>
               Raise_Exception
                 (Invalid_Code'Identity,
                  "code " & Unicode_Char'Image (Char)
                  & " is not available in Windows-1252");
         end case;
      end if;
   end To_Windows_1252;

end Unicode.CCS.Windows_1252;