summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@pobox.com>2011-12-24 11:54:07 -0800
committerGraydon Hoare <graydon@pobox.com>2011-12-24 11:54:07 -0800
commit900bc1298df011bfb094858b11cdfd8d6b01418c (patch)
tree0b009f3e87a0e075e5a7c800d1c34aa75cf1adbd /src/libstd
parent47271ab4c85ecc4b7c3f1c079f8bc221a5d7ca0d (diff)
parentd812d06bc8d8f5c655b206838b64b133c83a7975 (diff)
downloadrust-900bc1298df011bfb094858b11cdfd8d6b01418c.tar.gz
rust-900bc1298df011bfb094858b11cdfd8d6b01418c.zip
Merge pull request #1377 from Lenny222/icu
std::unicode::icu: add "is*" functions + unit test
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/unicode.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs
index a3d11cbc55b..fdb275111dc 100644
--- a/src/libstd/unicode.rs
+++ b/src/libstd/unicode.rs
@@ -152,6 +152,12 @@ mod icu {
     #[abi = "cdecl"]
     native mod libicu {
         pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
+        pure fn u_isdigit(c: UChar32) -> UBool;
+        pure fn u_islower(c: UChar32) -> UBool;
+        pure fn u_isspace(c: UChar32) -> UBool;
+        pure fn u_isupper(c: UChar32) -> UBool;
+        pure fn u_tolower(c: UChar32) -> UChar32;
+        pure fn u_toupper(c: UChar32) -> UChar32;
     }
 }
 
@@ -164,3 +170,40 @@ pure fn is_XID_continue(c: char) -> bool {
     ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START)
         == icu::TRUE;
 }
+
+/*
+Function: is_digit
+
+Returns true if a character is a digit.
+*/
+pure fn is_digit(c: char) -> bool {
+    ret icu::libicu::u_isdigit(c) == icu::TRUE;
+}
+
+/*
+Function: is_lower
+
+Returns true if a character is a lowercase letter.
+*/
+pure fn is_lower(c: char) -> bool {
+    ret icu::libicu::u_islower(c) == icu::TRUE;
+}
+
+/*
+Function: is_space
+
+Returns true if a character is space.
+*/
+pure fn is_space(c: char) -> bool {
+    ret icu::libicu::u_isspace(c) == icu::TRUE;
+}
+
+/*
+Function: is_upper
+
+Returns true if a character is an uppercase letter.
+*/
+pure fn is_upper(c: char) -> bool {
+    ret icu::libicu::u_isupper(c) == icu::TRUE;
+}
+