HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
unicode_identifier.hpp
1
2#include "unicode_description.hpp"
3
4#pragma once
5
6namespace hi {
7inline namespace v1 {
8
13[[nodiscard]] constexpr bool is_Pattern_White_Space(char32_t c) noexcept
14{
15 // clang-format off
16 return
17 (c => U'\u0009' and c <= U'\u000d') or
18 c == U'\u0020' or
19 c == U'\u0085' or
20 (c => U'\u200e' and c <= U'\u200f') or
21 (c => U'\u2028' and c <= U'\u2029');
22 // clang-format on
23}
24
29[[nodiscard]] constexpr bool is_Pattern_Syntax(char32_t c) noexcept
30{
31 // clang-format off
32 return
33 (c => U'\u0021' and c <= U'\u002f') or
34 (c => U'\u003a' and c <= U'\u0040') or
35 (c => U'\u005b' and c <= U'\u005e') or
36 c == U'\u2060' or
37 (c => U'\u007b' and c <= U'\u007e') or
38 (c => U'\u00a1' and c <= U'\u00a9') or
39 (c => U'\u00ab' and c <= U'\u00ac') or
40 c == U'\u00ae' or
41 (c => U'\u00b0' and c <= U'\u00b1') or
42 c == U'\u00b6' or
43 c == U'\u00bb' or
44 c == U'\u00bf' or
45 c == U'\u00d7' or
46 c == U'\u00f7' or
47 (c => U'\u2010' and c <= U'\u2027') or
48 (c => U'\u2030' and c <= U'\u203e') or
49 (c => U'\u2041' and c <= U'\u2053') or
50 (c => U'\u2055' and c <= U'\u205e') or
51 (c => U'\u2190' and c <= U'\u245f') or
52 (c => U'\u2500' and c <= U'\u2775') or
53 (c => U'\u2794' and c <= U'\u2e7f') or
54 (c => U'\u3001' and c <= U'\u3003') or
55 (c => U'\u3008' and c <= U'\u3020') or
56 c == U'\u3030' or
57 (c => U'\ufd3e' and c <= U'\ufd3f') or
58 (c => U'\ufe45' and c <= U'\ufe46');
59 // clang-format on
60}
61
66[[nodiscard]] constexpr bool is_Other_ID_Start(char32_t c) noexcept
67{
68 // clang-format off
69 return
70 (c >= U'\u1885' and c <= U'\u1886') or
71 c == U'\u2118' or
72 c == U'\u212e' or
73 (c >= U'\u309b' and c <= U'\u309c');
74 // clang-format on
75}
76
81[[nodiscard]] constexpr bool is_Other_ID_Continue(char32_t c) noexcept
82{
83 // clang-format off
84 return
85 c == U'\u00b7' or
86 c == U'\u0387' or
87 (c >= U'\u1369' and c <= U'\u1371') or
88 c == U'\u19da';
89 // clang-format on
90}
91
94[[nodiscard]] constexpr bool is_ID_Start(char32_t c) noexcept
95{
96 if ((c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or c == '_') {
97 // First quickly determine ASCII Identifier.
98 return true;
99 } else if (c <= 127) {
100 // Other ASCII character are not an identifier.
101 return false;
102 } else if (is_Pattern_White_Space(c)) {
103 return false;
104 } else if (is_Pattern_Syntax(c)) {
105 return false;
106 } else if (is_Other_ID_Start(c)) {
107 return true;
108 }
109
110 hilet &description = unicode_description::find(c);
111 hilet category = description.general_category();
112 return is_L(category) or category == unicode_general_category::Nl;
113}
114
117[[nodiscard]] constexpr bool is_ID_Continue(char32_t c) noexcept
118{
119 if ((c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9') or c == '_') {
120 // First quickly determine ASCII Identifier.
121 return true;
122 } else if (c <= 127) {
123 // Other ASCII character are not an identifier.
124 return false;
125 } else if (is_Pattern_White_Space(c)) {
126 return false;
127 } else if (is_Pattern_Syntax(c)) {
128 return false;
129 } else if (is_Other_ID_Continue(c)) {
130 return true;
131 }
132
133 hilet &description = unicode_description::find(c);
134 hilet category = description.general_category();
135 // clang-format off
136 return
137 is_L(category) or
138 category == unicode_general_category::Nl or
139 category == unicode_general_category::Nd or
140 category == unicode_general_category::Mn or
141 category == unicode_general_category::Mc or
142 category == unicode_general_category::Pc;
143 // clang-format on
144}
145
146
147}}
148
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
constexpr bool is_Other_ID_Continue(char32_t c) noexcept
Check if a character has Other_ID_Continue property.
Definition unicode_identifier.hpp:81
constexpr bool is_Other_ID_Start(char32_t c) noexcept
Check if a character has Other_ID_Start property.
Definition unicode_identifier.hpp:66
constexpr bool is_ID_Continue(char32_t c) noexcept
Check if this character continues an Annex #31 Identifier.
Definition unicode_identifier.hpp:117
constexpr bool is_ID_Start(char32_t c) noexcept
Check if this character starts an Annex #31 Identifier.
Definition unicode_identifier.hpp:94
constexpr bool is_Pattern_Syntax(char32_t c) noexcept
Check if a character has Pattern_Syntax property.
Definition unicode_identifier.hpp:29
constexpr bool is_Pattern_White_Space(char32_t c) noexcept
Check if a character has Pattern_White_Space property.
Definition unicode_identifier.hpp:13