Skip to content

Commit

Permalink
Redo rust-lang#81358 in unicode-table-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Oct 6, 2021
1 parent d480cef commit e159d42
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/tools/unicode-table-generator/src/case_mapping.rs
Expand Up @@ -41,18 +41,26 @@ impl fmt::Debug for CharEscape {
}
}

static HEADER: &str = "
static HEADER: &str = r"
pub fn to_lower(c: char) -> [char; 3] {
match bsearch_case_table(c, LOWERCASE_TABLE) {
None => [c, '\\0', '\\0'],
Some(index) => LOWERCASE_TABLE[index].1,
if c.is_ascii() {
[(c as u8).to_ascii_lowercase() as char, '\0', '\0']
} else {
match bsearch_case_table(c, LOWERCASE_TABLE) {
None => [c, '\0', '\0'],
Some(index) => LOWERCASE_TABLE[index].1,
}
}
}
pub fn to_upper(c: char) -> [char; 3] {
match bsearch_case_table(c, UPPERCASE_TABLE) {
None => [c, '\\0', '\\0'],
Some(index) => UPPERCASE_TABLE[index].1,
if c.is_ascii() {
[(c as u8).to_ascii_uppercase() as char, '\0', '\0']
} else {
match bsearch_case_table(c, UPPERCASE_TABLE) {
None => [c, '\0', '\0'],
Some(index) => UPPERCASE_TABLE[index].1,
}
}
}
Expand Down

0 comments on commit e159d42

Please sign in to comment.