1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . W C H _ W T S --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
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 with System
.WCh_Con
; use System
.WCh_Con
;
35 with System
.WCh_Cnv
; use System
.WCh_Cnv
;
37 package body System
.WCh_WtS
is
39 -----------------------
40 -- Local Subprograms --
41 -----------------------
43 procedure Store_UTF_32_Character
47 EM
: WC_Encoding_Method
);
48 -- Stores the string representation of the wide or wide wide character
49 -- whose code is given as U, starting at S (P + 1). P is incremented to
50 -- point to the last character stored. Raises CE if character cannot be
51 -- stored using the given encoding method.
53 ----------------------------
54 -- Store_UTF_32_Character --
55 ----------------------------
57 procedure Store_UTF_32_Character
61 EM
: WC_Encoding_Method
)
63 procedure Out_Char
(C
: Character);
64 pragma Inline
(Out_Char
);
65 -- Procedure to increment P and store C at S (P)
67 procedure Store_Chars
is new UTF_32_To_Char_Sequence
(Out_Char
);
73 procedure Out_Char
(C
: Character) is
81 end Store_UTF_32_Character
;
83 ---------------------------
84 -- Wide_String_To_String --
85 ---------------------------
87 function Wide_String_To_String
89 EM
: WC_Encoding_Method
) return String
91 R
: String (1 .. 5 * S
'Length); -- worst case length!
96 for SP
in S
'Range loop
97 Store_UTF_32_Character
(Wide_Character'Pos (S
(SP
)), R
, RP
, EM
);
101 end Wide_String_To_String
;
103 --------------------------------
104 -- Wide_Wide_Sring_To_String --
105 --------------------------------
107 function Wide_Wide_String_To_String
108 (S
: Wide_Wide_String
;
109 EM
: WC_Encoding_Method
) return String
111 R
: String (1 .. 7 * S
'Length); -- worst case length!
117 for SP
in S
'Range loop
118 Store_UTF_32_Character
(Wide_Wide_Character
'Pos (S
(SP
)), R
, RP
, EM
);
122 end Wide_Wide_String_To_String
;