File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ mod icu {
152152 #[ abi = "cdecl" ]
153153 native mod libicu {
154154 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 ;
155161 }
156162}
157163
@@ -164,3 +170,40 @@ pure fn is_XID_continue(c: char) -> bool {
164170 ret icu:: libicu:: u_hasBinaryProperty ( c, icu:: UCHAR_XID_START )
165171 == icu:: TRUE ;
166172}
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;
3939mod tri;
4040mod treemap;
4141mod uint;
42+
43+ #[cfg(unicode)]
44+ mod unicode;
45+
4246mod unsafe;
4347mod uv;
4448mod 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