Skip to content

Commit f365c9f

Browse files
committed
---
yaml --- r: 6945 b: refs/heads/master c: b3eb9a0 h: refs/heads/master i: 6943: 459982d v: v3
1 parent a1745b5 commit f365c9f

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: eb0cdc02e3b443fe119cb4957856a63dbd5923d4
2+
refs/heads/master: b3eb9a003165e800d2c48083d794cb9879f3be89

trunk/src/libstd/unicode.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff 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+

trunk/src/test/stdtest/stdtest.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ mod test;
3939
mod tri;
4040
mod treemap;
4141
mod uint;
42+
43+
#[cfg(unicode)]
44+
mod unicode;
45+
4246
mod unsafe;
4347
mod uv;
4448
mod vec;

trunk/src/test/stdtest/unicode.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+

0 commit comments

Comments
 (0)