1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef AAPT_TEXT_UNICODE_H
18 #define AAPT_TEXT_UNICODE_H
19 
20 #include "androidfw/StringPiece.h"
21 
22 namespace aapt {
23 namespace text {
24 
25 // Returns true if the Unicode codepoint has the XID_Start property, meaning it can be used as the
26 // first character of a programming language identifier.
27 // http://unicode.org/reports/tr31/#Default_Identifier_Syntax
28 //
29 // XID_Start is a Unicode Derived Core Property. It is a variation of the ID_Start
30 // Derived Core Property, accounting for a few characters that, when normalized, yield valid
31 // characters in the ID_Start set.
32 bool IsXidStart(char32_t codepoint);
33 
34 // Returns true if the Unicode codepoint has the XID_Continue property, meaning it can be used in
35 // any position of a programming language identifier, except the first.
36 // http://unicode.org/reports/tr31/#Default_Identifier_Syntax
37 //
38 // XID_Continue is a Unicode Derived Core Property. It is a variation of the ID_Continue
39 // Derived Core Property, accounting for a few characters that, when normalized, yield valid
40 // characters in the ID_Continue set.
41 bool IsXidContinue(char32_t codepoint);
42 
43 // Returns true if the Unicode codepoint has the White_Space property.
44 // http://unicode.org/reports/tr44/#White_Space
45 bool IsWhitespace(char32_t codepoint);
46 
47 // Returns true if the UTF8 string can be used as a Java identifier.
48 // NOTE: This does not check against the set of reserved Java keywords.
49 bool IsJavaIdentifier(const android::StringPiece& str);
50 
51 // Returns true if the UTF8 string can be used as the entry name of a resource name.
52 // This is the `entry` part of package:type/entry.
53 bool IsValidResourceEntryName(const android::StringPiece& str);
54 
55 }  // namespace text
56 }  // namespace aapt
57 
58 #endif  // AAPT_TEXT_UNICODE_H
59