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-2021, 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 -- Character_Set_Version -- 38 --------------------------- 39 40 function Character_Set_Version return String is 41 begin 42 return "Unicode 4.0"; 43 end Character_Set_Version; 44 45 --------------------- 46 -- Is_Alphanumeric -- 47 --------------------- 48 49 function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean is 50 begin 51 return Is_Letter (Item) or else Is_Digit (Item); 52 end Is_Alphanumeric; 53 54 -------------- 55 -- Is_Basic -- 56 -------------- 57 58 function Is_Basic (Item : Wide_Wide_Character) return Boolean 59 renames Ada.Wide_Wide_Characters.Unicode.Is_Basic; 60 61 ---------------- 62 -- Is_Control -- 63 ---------------- 64 65 function Is_Control (Item : Wide_Wide_Character) return Boolean is 66 begin 67 return Get_Category (Item) = Cc; 68 end Is_Control; 69 70 -------------- 71 -- Is_Digit -- 72 -------------- 73 74 function Is_Digit (Item : Wide_Wide_Character) return Boolean 75 renames Ada.Wide_Wide_Characters.Unicode.Is_Digit; 76 77 ---------------- 78 -- Is_Graphic -- 79 ---------------- 80 81 function Is_Graphic (Item : Wide_Wide_Character) return Boolean is 82 begin 83 return not Is_Non_Graphic (Item); 84 end Is_Graphic; 85 86 -------------------------- 87 -- Is_Hexadecimal_Digit -- 88 -------------------------- 89 90 function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean is 91 begin 92 return Is_Digit (Item) 93 or else Item in 'A' .. 'F' 94 or else Item in 'a' .. 'f'; 95 end Is_Hexadecimal_Digit; 96 97 --------------- 98 -- Is_Letter -- 99 --------------- 100 101 function Is_Letter (Item : Wide_Wide_Character) return Boolean 102 renames Ada.Wide_Wide_Characters.Unicode.Is_Letter; 103 104 ------------------------ 105 -- Is_Line_Terminator -- 106 ------------------------ 107 108 function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean 109 renames Ada.Wide_Wide_Characters.Unicode.Is_Line_Terminator; 110 111 -------------- 112 -- Is_Lower -- 113 -------------- 114 115 function Is_Lower (Item : Wide_Wide_Character) return Boolean is 116 begin 117 return Get_Category (Item) = Ll; 118 end Is_Lower; 119 120 ------------- 121 -- Is_Mark -- 122 ------------- 123 124 function Is_Mark (Item : Wide_Wide_Character) return Boolean 125 renames Ada.Wide_Wide_Characters.Unicode.Is_Mark; 126 127 ------------- 128 -- Is_NFKC -- 129 ------------- 130 131 function Is_NFKC (Item : Wide_Wide_Character) return Boolean 132 renames Ada.Wide_Wide_Characters.Unicode.Is_NFKC; 133 134 --------------------- 135 -- Is_Other_Format -- 136 --------------------- 137 138 function Is_Other_Format (Item : Wide_Wide_Character) return Boolean 139 renames Ada.Wide_Wide_Characters.Unicode.Is_Other; 140 141 ------------------------------ 142 -- Is_Punctuation_Connector -- 143 ------------------------------ 144 145 function Is_Punctuation_Connector 146 (Item : Wide_Wide_Character) return Boolean 147 renames Ada.Wide_Wide_Characters.Unicode.Is_Punctuation; 148 149 -------------- 150 -- Is_Space -- 151 -------------- 152 153 function Is_Space (Item : Wide_Wide_Character) return Boolean 154 renames Ada.Wide_Wide_Characters.Unicode.Is_Space; 155 156 ---------------- 157 -- Is_Special -- 158 ---------------- 159 160 function Is_Special (Item : Wide_Wide_Character) return Boolean is 161 begin 162 return Is_Graphic (Item) and then not Is_Alphanumeric (Item); 163 end Is_Special; 164 165 -------------- 166 -- Is_Upper -- 167 -------------- 168 169 function Is_Upper (Item : Wide_Wide_Character) return Boolean is 170 begin 171 return Get_Category (Item) = Lu; 172 end Is_Upper; 173 174 -------------- 175 -- To_Lower -- 176 -------------- 177 178 function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character 179 renames Ada.Wide_Wide_Characters.Unicode.To_Lower_Case; 180 181 function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String is 182 Result : Wide_Wide_String (Item'Range); 183 184 begin 185 for J in Result'Range loop 186 Result (J) := To_Lower (Item (J)); 187 end loop; 188 189 return Result; 190 end To_Lower; 191 192 -------------- 193 -- To_Upper -- 194 -------------- 195 196 function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character 197 renames Ada.Wide_Wide_Characters.Unicode.To_Upper_Case; 198 199 function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String is 200 Result : Wide_Wide_String (Item'Range); 201 202 begin 203 for J in Result'Range loop 204 Result (J) := To_Upper (Item (J)); 205 end loop; 206 207 return Result; 208 end To_Upper; 209 210 -------------- 211 -- To_Basic -- 212 -------------- 213 214 function To_Basic (Item : Wide_Wide_Character) return Wide_Wide_Character 215 renames Ada.Wide_Wide_Characters.Unicode.To_Basic; 216 217 function To_Basic (Item : Wide_Wide_String) return Wide_Wide_String is 218 Result : Wide_Wide_String (Item'Range); 219 220 begin 221 for J in Result'Range loop 222 Result (J) := To_Basic (Item (J)); 223 end loop; 224 225 return Result; 226 end To_Basic; 227 228end Ada.Wide_Wide_Characters.Handling; 229