1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT RUN-TIME COMPONENTS                         --
4--                                                                          --
5--    A D A . W I D E _ W I D E _ C H A R A C T E R S . H A N D L I N G     --
6--                                                                          --
7--                                 B o d y                                  --
8--                                                                          --
9--          Copyright (C) 2010-2020, Free Software Foundation, Inc.         --
10--                                                                          --
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 3,  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.                                     --
17--                                                                          --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
21--                                                                          --
22-- You should have received a copy of the GNU General Public License and    --
23-- a copy of the GCC Runtime Library Exception along with this program;     --
24-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25-- <http://www.gnu.org/licenses/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32with Ada.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode;
33
34package body Ada.Wide_Wide_Characters.Handling is
35
36   ---------------------
37   -- Is_Alphanumeric --
38   ---------------------
39
40   function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean is
41   begin
42      return Is_Letter (Item) or else Is_Digit (Item);
43   end Is_Alphanumeric;
44
45   ----------------
46   -- Is_Control --
47   ----------------
48
49   function Is_Control (Item : Wide_Wide_Character) return Boolean is
50   begin
51      return Get_Category (Item) = Cc;
52   end Is_Control;
53
54   --------------
55   -- Is_Digit --
56   --------------
57
58   function Is_Digit (Item : Wide_Wide_Character) return Boolean
59     renames Ada.Wide_Wide_Characters.Unicode.Is_Digit;
60
61   ----------------
62   -- Is_Graphic --
63   ----------------
64
65   function Is_Graphic (Item : Wide_Wide_Character) return Boolean is
66   begin
67      return not Is_Non_Graphic (Item);
68   end Is_Graphic;
69
70   --------------------------
71   -- Is_Hexadecimal_Digit --
72   --------------------------
73
74   function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean is
75   begin
76      return Is_Digit (Item)
77        or else Item in 'A' .. 'F'
78        or else Item in 'a' .. 'f';
79   end Is_Hexadecimal_Digit;
80
81   ---------------
82   -- Is_Letter --
83   ---------------
84
85   function Is_Letter (Item : Wide_Wide_Character) return Boolean
86     renames Ada.Wide_Wide_Characters.Unicode.Is_Letter;
87
88   ------------------------
89   -- Is_Line_Terminator --
90   ------------------------
91
92   function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean
93     renames Ada.Wide_Wide_Characters.Unicode.Is_Line_Terminator;
94
95   --------------
96   -- Is_Lower --
97   --------------
98
99   function Is_Lower (Item : Wide_Wide_Character) return Boolean is
100   begin
101      return Get_Category (Item) = Ll;
102   end Is_Lower;
103
104   -------------
105   -- Is_Mark --
106   -------------
107
108   function Is_Mark (Item : Wide_Wide_Character) return Boolean
109     renames Ada.Wide_Wide_Characters.Unicode.Is_Mark;
110
111   -------------
112   -- Is_NFKC --
113   -------------
114
115   function Is_NFKC (Item : Wide_Wide_Character) return Boolean
116     renames Ada.Wide_Wide_Characters.Unicode.Is_NFKC;
117
118   ---------------------
119   -- Is_Other_Format --
120   ---------------------
121
122   function Is_Other_Format (Item : Wide_Wide_Character) return Boolean
123     renames Ada.Wide_Wide_Characters.Unicode.Is_Other;
124
125   ------------------------------
126   -- Is_Punctuation_Connector --
127   ------------------------------
128
129   function Is_Punctuation_Connector
130     (Item : Wide_Wide_Character) return Boolean
131     renames Ada.Wide_Wide_Characters.Unicode.Is_Punctuation;
132
133   --------------
134   -- Is_Space --
135   --------------
136
137   function Is_Space (Item : Wide_Wide_Character) return Boolean
138     renames Ada.Wide_Wide_Characters.Unicode.Is_Space;
139
140   ----------------
141   -- Is_Special --
142   ----------------
143
144   function Is_Special (Item : Wide_Wide_Character) return Boolean is
145   begin
146      return Is_Graphic (Item) and then not Is_Alphanumeric (Item);
147   end Is_Special;
148
149   --------------
150   -- Is_Upper --
151   --------------
152
153   function Is_Upper (Item : Wide_Wide_Character) return Boolean is
154   begin
155      return Get_Category (Item) = Lu;
156   end Is_Upper;
157
158   --------------
159   -- To_Lower --
160   --------------
161
162   function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character
163     renames Ada.Wide_Wide_Characters.Unicode.To_Lower_Case;
164
165   function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String is
166      Result : Wide_Wide_String (Item'Range);
167
168   begin
169      for J in Result'Range loop
170         Result (J) := To_Lower (Item (J));
171      end loop;
172
173      return Result;
174   end To_Lower;
175
176   --------------
177   -- To_Upper --
178   --------------
179
180   function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character
181     renames Ada.Wide_Wide_Characters.Unicode.To_Upper_Case;
182
183   function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String is
184      Result : Wide_Wide_String (Item'Range);
185
186   begin
187      for J in Result'Range loop
188         Result (J) := To_Upper (Item (J));
189      end loop;
190
191      return Result;
192   end To_Upper;
193
194end Ada.Wide_Wide_Characters.Handling;
195