PR target/84827
[official-gcc.git] / gcc / ada / libgnat / s-wchcon.adb
blob8a5c874f4ec25d3804762e1f5df4f4f83f588be6
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-2018, 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 ------------------------------------------------------------------------------
32 pragma Compiler_Unit_Warning;
34 package body System.WCh_Con is
36 ----------------------------
37 -- Get_WC_Encoding_Method --
38 ----------------------------
40 function Get_WC_Encoding_Method (C : Character) return WC_Encoding_Method is
41 begin
42 for Method in WC_Encoding_Method loop
43 if C = WC_Encoding_Letters (Method) then
44 return Method;
45 end if;
46 end loop;
48 raise Constraint_Error;
49 end Get_WC_Encoding_Method;
51 function Get_WC_Encoding_Method (S : String) return WC_Encoding_Method is
52 begin
53 if S = "hex" then
54 return WCEM_Hex;
55 elsif S = "upper" then
56 return WCEM_Upper;
57 elsif S = "shift_jis" then
58 return WCEM_Shift_JIS;
59 elsif S = "euc" then
60 return WCEM_EUC;
61 elsif S = "utf8" then
62 return WCEM_UTF8;
63 elsif S = "brackets" then
64 return WCEM_Brackets;
65 else
66 raise Constraint_Error;
67 end if;
68 end Get_WC_Encoding_Method;
70 --------------------------
71 -- Is_Start_Of_Encoding --
72 --------------------------
74 function Is_Start_Of_Encoding
75 (C : Character;
76 EM : WC_Encoding_Method) return Boolean
78 begin
79 return (EM in WC_Upper_Half_Encoding_Method
80 and then Character'Pos (C) >= 16#80#)
81 or else (EM in WC_ESC_Encoding_Method and then C = ASCII.ESC);
82 end Is_Start_Of_Encoding;
84 end System.WCh_Con;