File tree 3 files changed +77
-0
lines changed
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ mod icu {
152
152
#[ abi = "cdecl" ]
153
153
native mod libicu {
154
154
pure fn u_hasBinaryProperty ( c : UChar32 , which : UProperty ) -> UBool ;
155
+ pure fn u_isdigit ( c : UChar32 ) -> UBool ;
156
+ pure fn u_islower ( c : UChar32 ) -> UBool ;
157
+ pure fn u_isspace ( c : UChar32 ) -> UBool ;
158
+ pure fn u_isupper ( c : UChar32 ) -> UBool ;
159
+ pure fn u_tolower ( c : UChar32 ) -> UChar32 ;
160
+ pure fn u_toupper ( c : UChar32 ) -> UChar32 ;
155
161
}
156
162
}
157
163
@@ -164,3 +170,40 @@ pure fn is_XID_continue(c: char) -> bool {
164
170
ret icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
165
171
== icu:: TRUE ;
166
172
}
173
+
174
+ /*
175
+ Function: is_digit
176
+
177
+ Returns true if a character is a digit.
178
+ */
179
+ pure fn is_digit ( c : char ) -> bool {
180
+ ret icu:: libicu:: u_isdigit ( c) == icu:: TRUE ;
181
+ }
182
+
183
+ /*
184
+ Function: is_lower
185
+
186
+ Returns true if a character is a lowercase letter.
187
+ */
188
+ pure fn is_lower ( c : char ) -> bool {
189
+ ret icu:: libicu:: u_islower ( c) == icu:: TRUE ;
190
+ }
191
+
192
+ /*
193
+ Function: is_space
194
+
195
+ Returns true if a character is space.
196
+ */
197
+ pure fn is_space ( c : char ) -> bool {
198
+ ret icu:: libicu:: u_isspace ( c) == icu:: TRUE ;
199
+ }
200
+
201
+ /*
202
+ Function: is_upper
203
+
204
+ Returns true if a character is an uppercase letter.
205
+ */
206
+ pure fn is_upper ( c : char ) -> bool {
207
+ ret icu:: libicu:: u_isupper ( c) == icu:: TRUE ;
208
+ }
209
+
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ mod test;
39
39
mod tri;
40
40
mod treemap;
41
41
mod uint;
42
+
43
+ #[cfg(unicode)]
44
+ mod unicode;
45
+
42
46
mod unsafe;
43
47
mod uv;
44
48
mod vec;
Original file line number Diff line number Diff line change
1
+ import core:: * ;
2
+
3
+ use std;
4
+
5
+ import unicode;
6
+
7
+ #[ test]
8
+ fn test_is_digit ( ) {
9
+ assert ( unicode:: icu:: is_digit ( '0' ) ) ;
10
+ assert ( !unicode:: icu:: is_digit ( 'm' ) ) ;
11
+ }
12
+
13
+ #[ test]
14
+ fn test_is_lower ( ) {
15
+ assert ( unicode:: icu:: is_lower ( 'm' ) ) ;
16
+ assert ( !unicode:: icu:: is_lower ( 'M' ) ) ;
17
+ }
18
+
19
+ #[ test]
20
+ fn test_is_space ( ) {
21
+ assert ( unicode:: icu:: is_space ( ' ' ) ) ;
22
+ assert ( !unicode:: icu:: is_space ( 'm' ) ) ;
23
+ }
24
+
25
+ #[ test]
26
+ fn test_is_upper ( ) {
27
+ assert ( unicode:: icu:: is_upper ( 'M' ) ) ;
28
+ assert ( !unicode:: icu:: is_upper ( 'm' ) ) ;
29
+ }
30
+
You can’t perform that action at this time.
0 commit comments