1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- G N A T . U T F _ 3 2 --
9 -- Copyright (C) 2005 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package is an internal package that provides basic character
35 -- classification capabilities needed by the compiler for handling full
36 -- 32-bit wide wide characters. We avoid the use of the actual type
37 -- Wide_Wide_Character, since we want to use these routines in the compiler
38 -- itself, and we want to be able to compile the compiler with old versions
39 -- of GNAT that did not implement Wide_Wide_Character.
41 -- This package is not available directly for use in application programs,
42 -- but it serves as the basis for GNAT.Wide_Case_Utilities and
43 -- GNAT.Wide_Wide_Case_Utilities, which can be used directly.
45 package GNAT
.UTF_32
is
47 type UTF_32
is mod 2 ** 32;
48 -- The actual allowed range is 16#00_0000# .. 16#01_FFFF#
50 function Is_UTF_32_Letter
(U
: UTF_32
) return Boolean;
51 pragma Inline
(Is_UTF_32_Letter
);
52 -- Returns true iff U is a letter that can be used to start an identifier.
53 -- This means that it is in one of the following categories:
54 -- Letter, Uppercase (Lu)
55 -- Letter, Lowercase (Ll)
56 -- Letter, Titlecase (Lt)
57 -- Letter, Modifier (Lm)
59 -- Number, Letter (Nl)
61 function Is_UTF_32_Digit
(U
: UTF_32
) return Boolean;
62 pragma Inline
(Is_UTF_32_Digit
);
63 -- Returns true iff U is a digit that can be used to extend an identifer,
64 -- which means it is in one of the following categories:
65 -- Number, Decimal_Digit (Nd)
67 function Is_UTF_32_Line_Terminator
(U
: UTF_32
) return Boolean;
68 pragma Inline
(Is_UTF_32_Line_Terminator
);
69 -- Returns true iff U is an allowed line terminator for source programs,
70 -- which means it is in one of the following categories:
71 -- Separator, Line (Zl)
72 -- Separator, Paragraph (Zp)
73 -- or that it is a conventional line terminator (CR, LF, VT, FF)
75 function Is_UTF_32_Mark
(U
: UTF_32
) return Boolean;
76 pragma Inline
(Is_UTF_32_Mark
);
77 -- Returns true iff U is a mark character which can be used to extend
78 -- an identifier. This means it is in one of the following categories:
79 -- Mark, Non-Spacing (Mn)
80 -- Mark, Spacing Combining (Mc)
82 function Is_UTF_32_Other
(U
: UTF_32
) return Boolean;
83 pragma Inline
(Is_UTF_32_Other
);
84 -- Returns true iff U is an other format character, which means that it
85 -- can be used to extend an identifier, but is ignored for the purposes of
86 -- matching of identiers. This means that it is in one of the following
90 function Is_UTF_32_Punctuation
(U
: UTF_32
) return Boolean;
91 pragma Inline
(Is_UTF_32_Punctuation
);
92 -- Returns true iff U is a punctuation character that can be used to
93 -- separate pices of an identifier. This means that it is in one of the
94 -- following categories:
95 -- Punctuation, Connector (Pc)
97 function Is_UTF_32_Space
(U
: UTF_32
) return Boolean;
98 pragma Inline
(Is_UTF_32_Space
);
99 -- Returns true iff U is considered a space to be ignored, which means
100 -- that it is in one of the following categories:
101 -- Separator, Space (Zs)
103 function Is_UTF_32_Non_Graphic
(U
: UTF_32
) return Boolean;
104 pragma Inline
(Is_UTF_32_Non_Graphic
);
105 -- Returns true iff U is considered to be a non-graphic character,
106 -- which means that it is in one of the following categories:
107 -- Other, Control (Cc)
108 -- Other, Private Use (Co)
109 -- Other, Surrogate (Cs)
110 -- Other, Format (Cf)
111 -- Separator, Line (Zl)
112 -- Separator, Paragraph (Zp)
114 -- Note that the Ada category format effector is subsumed by the above
115 -- list of Unicode categories.
117 function UTF_32_To_Upper_Case
(U
: UTF_32
) return UTF_32
;
118 pragma Inline
(UTF_32_To_Upper_Case
);
119 -- If U represents a lower case letter, returns the corresponding upper
120 -- case letter, otherwise U is returned unchanged. The folding is locale
121 -- independent as defined by documents referenced in the note in section
122 -- 1 of ISO/IEC 10646:2003