"char": use shorter names "to_lower"/"to_upper", analogous to the same names in "str"

This commit is contained in:
Lenny222 2012-01-02 21:29:44 +01:00 committed by Marijn Haverbeke
parent e12b169247
commit dd284eb396
3 changed files with 17 additions and 17 deletions

View file

@ -41,7 +41,7 @@ export is_alphabetic,
is_XID_start, is_XID_continue,
is_lowercase, is_uppercase,
is_whitespace, is_alphanumeric,
to_digit, to_lowercase, to_uppercase, maybe_digit, cmp;
to_digit, to_lower, to_upper, maybe_digit, cmp;
import is_alphabetic = unicode::derived_property::Alphabetic;
import is_XID_start = unicode::derived_property::XID_Start;
@ -137,13 +137,13 @@ pure fn maybe_digit(c: char) -> option::t<u8> {
}
/*
Function: to_lowercase
Function: to_lower
Convert a char to the corresponding lower case.
FIXME: works only on ASCII
*/
pure fn to_lowercase(c: char) -> char {
pure fn to_lower(c: char) -> char {
alt c {
'A' to 'Z' { ((c as u8) + 32u8) as char }
_ { c }
@ -151,13 +151,13 @@ pure fn to_lowercase(c: char) -> char {
}
/*
Function: to_uppercase
Function: to_upper
Convert a char to the corresponding upper case.
FIXME: works only on ASCII
*/
pure fn to_uppercase(c: char) -> char {
pure fn to_upper(c: char) -> char {
alt c {
'a' to 'z' { ((c as u8) - 32u8) as char }
_ { c }

View file

@ -833,7 +833,7 @@ Convert a string to lowercase
fn to_lower(s: str) -> str {
let outstr = "";
iter_chars(s) { |c|
push_char(outstr, char::to_lowercase(c));
push_char(outstr, char::to_lower(c));
}
ret outstr;
}
@ -845,7 +845,7 @@ Convert a string to uppercase
fn to_upper(s: str) -> str {
let outstr = "";
iter_chars(s) { |c|
push_char(outstr, char::to_uppercase(c));
push_char(outstr, char::to_upper(c));
}
ret outstr;
}

View file

@ -62,17 +62,17 @@ fn test_to_digit_fail_2() {
}
#[test]
fn test_to_lowercase() {
assert (char::to_lowercase('H') == 'h');
assert (char::to_lowercase('e') == 'e');
//assert (char::to_lowercase('Ö') == 'ö');
assert (char::to_lowercase('ß') == 'ß');
fn test_to_lower() {
assert (char::to_lower('H') == 'h');
assert (char::to_lower('e') == 'e');
//assert (char::to_lower('Ö') == 'ö');
assert (char::to_lower('ß') == 'ß');
}
#[test]
fn test_to_uppercase() {
assert (char::to_uppercase('l') == 'L');
assert (char::to_uppercase('Q') == 'Q');
//assert (char::to_uppercase('ü') == 'Ü');
assert (char::to_uppercase('ß') == 'ß');
fn test_to_upper() {
assert (char::to_upper('l') == 'L');
assert (char::to_upper('Q') == 'Q');
//assert (char::to_upper('ü') == 'Ü');
assert (char::to_upper('ß') == 'ß');
}