diff options
| author | Josh Stone <jistone@redhat.com> | 2021-10-06 15:45:17 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2021-10-06 15:45:17 -0700 |
| commit | e159d42a9a4747f4b35396d08c7d8d9913cbcf83 (patch) | |
| tree | 0d3757462d184983b7a445b8f2d68f9ae8570d6d | |
| parent | d480ceff384f80394e9367b5e9d3596d62f20585 (diff) | |
| download | rust-e159d42a9a4747f4b35396d08c7d8d9913cbcf83.tar.gz rust-e159d42a9a4747f4b35396d08c7d8d9913cbcf83.zip | |
Redo #81358 in unicode-table-generator
| -rw-r--r-- | src/tools/unicode-table-generator/src/case_mapping.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tools/unicode-table-generator/src/case_mapping.rs b/src/tools/unicode-table-generator/src/case_mapping.rs index 01f199c213e..992aac1f857 100644 --- a/src/tools/unicode-table-generator/src/case_mapping.rs +++ b/src/tools/unicode-table-generator/src/case_mapping.rs @@ -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, + } } } |
