| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- S Y S T E M . W C H _ C O N -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2005-2025, 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 |
|
| 32 |
package body System.WCh_Con is |
| 33 |
|
| 34 |
---------------------------- |
| 35 |
-- Get_WC_Encoding_Method -- |
| 36 |
---------------------------- |
| 37 |
|
| 38 |
function Get_WC_Encoding_Method (C : Character) return WC_Encoding_Method is |
| 39 |
begin |
| 40 |
for Method in WC_Encoding_Method loop |
| 41 |
if C = WC_Encoding_Letters (Method) then |
| 42 |
return Method; |
| 43 |
end if; |
| 44 |
end loop; |
| 45 |
|
| 46 |
raise Constraint_Error; |
| 47 |
end Get_WC_Encoding_Method; |
| 48 |
|
| 49 |
function Get_WC_Encoding_Method (S : String) return WC_Encoding_Method is |
| 50 |
begin |
| 51 |
if S = "hex" then |
| 52 |
return WCEM_Hex; |
| 53 |
elsif S = "upper" then |
| 54 |
return WCEM_Upper; |
| 55 |
elsif S = "shift_jis" then |
| 56 |
return WCEM_Shift_JIS; |
| 57 |
elsif S = "euc" then |
| 58 |
return WCEM_EUC; |
| 59 |
elsif S = "utf8" then |
| 60 |
return WCEM_UTF8; |
| 61 |
elsif S = "brackets" then |
| 62 |
return WCEM_Brackets; |
| 63 |
else |
| 64 |
raise Constraint_Error; |
| 65 |
end if; |
| 66 |
end Get_WC_Encoding_Method; |
| 67 |
|
| 68 |
-------------------------- |
| 69 |
-- Is_Start_Of_Encoding -- |
| 70 |
-------------------------- |
| 71 |
|
| 72 |
function Is_Start_Of_Encoding |
| 73 |
(C : Character; |
| 74 |
EM : WC_Encoding_Method) return Boolean |
| 75 |
is |
| 76 |
begin |
| 77 |
return (EM in WC_Upper_Half_Encoding_Method |
| 78 |
and then Character'Pos (C) >= 16#80#) |
| 79 |
or else (EM in WC_ESC_Encoding_Method and then C = ASCII.ESC); |
| 80 |
end Is_Start_Of_Encoding; |
| 81 |
|
| 82 |
end System.WCh_Con; |