1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ C H A R A C T E R S . H A N D L I N G --
9 -- Copyright (C) 2010-2023, 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 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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Wide_Characters
.Unicode
; use Ada
.Wide_Characters
.Unicode
;
34 package body Ada
.Wide_Characters
.Handling
is
36 ---------------------------
37 -- Character_Set_Version --
38 ---------------------------
40 function Character_Set_Version
return String is
43 end Character_Set_Version
;
49 function Is_Alphanumeric
(Item
: Wide_Character) return Boolean is
51 return Is_Letter
(Item
) or else Is_Digit
(Item
);
58 function Is_Basic
(Item
: Wide_Character) return Boolean
59 renames Ada
.Wide_Characters
.Unicode
.Is_Basic
;
65 function Is_Control
(Item
: Wide_Character) return Boolean is
67 return Get_Category
(Item
) = Cc
;
74 function Is_Digit
(Item
: Wide_Character) return Boolean
75 renames Ada
.Wide_Characters
.Unicode
.Is_Digit
;
81 function Is_Graphic
(Item
: Wide_Character) return Boolean is
83 return not Is_Non_Graphic
(Item
);
86 --------------------------
87 -- Is_Hexadecimal_Digit --
88 --------------------------
90 function Is_Hexadecimal_Digit
(Item
: Wide_Character) return Boolean is
92 return Is_Digit
(Item
)
93 or else Item
in 'A' .. 'F'
94 or else Item
in 'a' .. 'f';
95 end Is_Hexadecimal_Digit
;
101 function Is_Letter
(Item
: Wide_Character) return Boolean
102 renames Ada
.Wide_Characters
.Unicode
.Is_Letter
;
104 ------------------------
105 -- Is_Line_Terminator --
106 ------------------------
108 function Is_Line_Terminator
(Item
: Wide_Character) return Boolean
109 renames Ada
.Wide_Characters
.Unicode
.Is_Line_Terminator
;
115 function Is_Lower
(Item
: Wide_Character) return Boolean is
117 return Get_Category
(Item
) = Ll
;
124 function Is_Mark
(Item
: Wide_Character) return Boolean
125 renames Ada
.Wide_Characters
.Unicode
.Is_Mark
;
131 function Is_NFKC
(Item
: Wide_Character) return Boolean
132 renames Ada
.Wide_Characters
.Unicode
.Is_NFKC
;
134 ---------------------
135 -- Is_Other_Format --
136 ---------------------
138 function Is_Other_Format
(Item
: Wide_Character) return Boolean
139 renames Ada
.Wide_Characters
.Unicode
.Is_Other
;
141 ------------------------------
142 -- Is_Punctuation_Connector --
143 ------------------------------
145 function Is_Punctuation_Connector
(Item
: Wide_Character) return Boolean
146 renames Ada
.Wide_Characters
.Unicode
.Is_Punctuation
;
152 function Is_Space
(Item
: Wide_Character) return Boolean
153 renames Ada
.Wide_Characters
.Unicode
.Is_Space
;
159 function Is_Special
(Item
: Wide_Character) return Boolean is
161 return Is_Graphic
(Item
) and then not Is_Alphanumeric
(Item
);
168 function Is_Upper
(Item
: Wide_Character) return Boolean is
170 return Get_Category
(Item
) = Lu
;
177 function To_Lower
(Item
: Wide_Character) return Wide_Character
178 renames Ada
.Wide_Characters
.Unicode
.To_Lower_Case
;
180 function To_Lower
(Item
: Wide_String) return Wide_String is
181 Result
: Wide_String (Item
'Range);
184 for J
in Result
'Range loop
185 Result
(J
) := To_Lower
(Item
(J
));
195 function To_Upper
(Item
: Wide_Character) return Wide_Character
196 renames Ada
.Wide_Characters
.Unicode
.To_Upper_Case
;
198 function To_Upper
(Item
: Wide_String) return Wide_String is
199 Result
: Wide_String (Item
'Range);
202 for J
in Result
'Range loop
203 Result
(J
) := To_Upper
(Item
(J
));
213 function To_Basic
(Item
: Wide_Character) return Wide_Character
214 renames Ada
.Wide_Characters
.Unicode
.To_Basic
;
216 function To_Basic
(Item
: Wide_String) return Wide_String is
217 Result
: Wide_String (Item
'Range);
220 for J
in Result
'Range loop
221 Result
(J
) := To_Basic
(Item
(J
));
227 end Ada
.Wide_Characters
.Handling
;