]>
Commit | Line | Data |
---|---|---|
6f301919 AC |
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 | -- -- | |
4b490c1e | 9 | -- Copyright (C) 2005-2020, Free Software Foundation, Inc. -- |
6f301919 AC |
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- -- | |
748086b7 | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
6f301919 AC |
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 -- | |
748086b7 JJ |
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/>. -- | |
6f301919 AC |
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 | ||
e917e3b8 | 32 | pragma Compiler_Unit_Warning; |
2d9ea47f | 33 | |
6f301919 AC |
34 | package body System.WCh_Con is |
35 | ||
36 | ---------------------------- | |
37 | -- Get_WC_Encoding_Method -- | |
38 | ---------------------------- | |
39 | ||
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; | |
47 | ||
48 | raise Constraint_Error; | |
49 | end Get_WC_Encoding_Method; | |
50 | ||
bfc8aa81 RD |
51 | function Get_WC_Encoding_Method (S : String) return WC_Encoding_Method is |
52 | begin | |
835d23b2 RD |
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; | |
bfc8aa81 RD |
65 | else |
66 | raise Constraint_Error; | |
67 | end if; | |
68 | end Get_WC_Encoding_Method; | |
69 | ||
b917101e RD |
70 | -------------------------- |
71 | -- Is_Start_Of_Encoding -- | |
72 | -------------------------- | |
73 | ||
74 | function Is_Start_Of_Encoding | |
75 | (C : Character; | |
76 | EM : WC_Encoding_Method) return Boolean | |
77 | is | |
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; | |
83 | ||
6f301919 | 84 | end System.WCh_Con; |