blob: 270718734cff2b0183f9c0c7e8f51d45bb9a4dcf [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
43// Returns true if the UTF8 string can be used as a Java identifier.
44// NOTE: This does not check against the set of reserved Java keywords.
45bool IsJavaIdentifier(const android::StringPiece& str);
46
47// Returns true if the UTF8 string can be used as the entry name of a resource name.
48// This is the `entry` part of package:type/entry.
49bool IsValidResourceEntryName(const android::StringPiece& str);
50
51} // namespace text
52} // namespace aapt
53
54#endif // AAPT_TEXT_UNICODE_H