blob: 546714e9a29089702fa63675cf9aa7438a98493e [file] [log] [blame]
Adam Lesinski66ea8402017-06-28 11:44:11 -07001/*
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
22namespace aapt {
23namespace 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.
32bool 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.
41bool IsXidContinue(char32_t codepoint);
42
Adam Lesinski18dc03a2017-07-24 18:19:36 -070043// Returns true if the Unicode codepoint has the White_Space property.
44// http://unicode.org/reports/tr44/#White_Space
45bool IsWhitespace(char32_t codepoint);
46
Adam Lesinski66ea8402017-06-28 11:44:11 -070047// 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.
49bool 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.
53bool IsValidResourceEntryName(const android::StringPiece& str);
54
55} // namespace text
56} // namespace aapt
57
58#endif // AAPT_TEXT_UNICODE_H