1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- ADA.STRINGS.UTF_ENCODING.WIDE_STRINGS --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- This specification is derived from the Ada Reference Manual for use with --
|
10 |
|
|
-- GNAT. In accordance with the copyright of that document, you can freely --
|
11 |
|
|
-- copy and modify this specification, provided that if you redistribute a --
|
12 |
|
|
-- modified version, any changes that you have made are clearly indicated. --
|
13 |
|
|
-- --
|
14 |
|
|
------------------------------------------------------------------------------
|
15 |
|
|
|
16 |
|
|
-- This is an Ada 2012 package defined in AI05-0137-1. It is used for encoding
|
17 |
|
|
-- and decoding Wide_String values using UTF encodings. Note: this package is
|
18 |
|
|
-- consistent with Ada 95, and may be included in Ada 95 implementations.
|
19 |
|
|
|
20 |
|
|
package Ada.Strings.UTF_Encoding.Wide_Strings is
|
21 |
|
|
pragma Pure (Wide_Strings);
|
22 |
|
|
|
23 |
|
|
-- The encoding routines take a Wide_String as input and encode the result
|
24 |
|
|
-- using the specified UTF encoding method. The result includes a BOM if
|
25 |
|
|
-- the Output_BOM argument is set to True. Encoding_Error is raised if an
|
26 |
|
|
-- invalid character appears in the input. In particular the characters
|
27 |
|
|
-- in the range 16#D800# .. 16#DFFF# are invalid because they conflict
|
28 |
|
|
-- with UTF-16 surrogate encodings, and the characters 16#FFFE# and
|
29 |
|
|
-- 16#FFFF# are also invalid because they conflict with BOM codes.
|
30 |
|
|
|
31 |
|
|
function Encode
|
32 |
|
|
(Item : Wide_String;
|
33 |
|
|
Output_Scheme : Encoding_Scheme;
|
34 |
|
|
Output_BOM : Boolean := False) return UTF_String;
|
35 |
|
|
-- Encode Wide_String using UTF-8, UTF-16LE or UTF-16BE encoding as
|
36 |
|
|
-- specified by the Output_Scheme parameter.
|
37 |
|
|
|
38 |
|
|
function Encode
|
39 |
|
|
(Item : Wide_String;
|
40 |
|
|
Output_BOM : Boolean := False) return UTF_8_String;
|
41 |
|
|
-- Encode Wide_String using UTF-8 encoding
|
42 |
|
|
|
43 |
|
|
function Encode
|
44 |
|
|
(Item : Wide_String;
|
45 |
|
|
Output_BOM : Boolean := False) return UTF_16_Wide_String;
|
46 |
|
|
-- Encode Wide_String using UTF_16 encoding
|
47 |
|
|
|
48 |
|
|
-- The decoding routines take a UTF String as input, and return a decoded
|
49 |
|
|
-- Wide_String. If the UTF String starts with a BOM that matches the
|
50 |
|
|
-- encoding method, it is ignored. An incorrect BOM raises Encoding_Error.
|
51 |
|
|
|
52 |
|
|
function Decode
|
53 |
|
|
(Item : UTF_String;
|
54 |
|
|
Input_Scheme : Encoding_Scheme) return Wide_String;
|
55 |
|
|
-- The input is encoded in UTF_8, UTF_16LE or UTF_16BE as specified by the
|
56 |
|
|
-- Input_Scheme parameter. It is decoded and returned as a Wide_String
|
57 |
|
|
-- value. Note: a convenient form for scheme may be Encoding (UTF_String).
|
58 |
|
|
|
59 |
|
|
function Decode
|
60 |
|
|
(Item : UTF_8_String) return Wide_String;
|
61 |
|
|
-- The input is encoded in UTF-8 and returned as a Wide_String value
|
62 |
|
|
|
63 |
|
|
function Decode
|
64 |
|
|
(Item : UTF_16_Wide_String) return Wide_String;
|
65 |
|
|
-- The input is encoded in UTF-16 and returned as a Wide_String value
|
66 |
|
|
|
67 |
|
|
end Ada.Strings.UTF_Encoding.Wide_Strings;
|