Skip to content

Commit a22c25c

Browse files
committed
Fix unctrl_lower casemapping
* `unctrl_lower` no longer transforms symbol characters; e.g. `]` to `}`
1 parent 62fc0c5 commit a22c25c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/chars.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,14 @@ pub fn unctrl(c: char) -> char {
123123
((c as u8) | CTRL_BIT) as char
124124
}
125125

126-
const CASE_BIT: u8 = 0x20;
127-
128126
/// Returns the lowercase character corresponding to the given control character.
129127
pub fn unctrl_lower(c: char) -> char {
130-
((c as u8) | CTRL_BIT | CASE_BIT) as char
128+
unctrl(c).to_ascii_lowercase()
131129
}
132130

133131
#[cfg(test)]
134132
mod test {
135-
use super::{ctrl, unctrl, escape_sequence, parse_char_name};
133+
use super::{ctrl, unctrl, unctrl_lower, escape_sequence, parse_char_name};
136134

137135
#[test]
138136
fn test_ctrl() {
@@ -147,6 +145,12 @@ mod test {
147145
assert_eq!(unctrl('\r'), 'M');
148146
}
149147

148+
#[test]
149+
fn test_unctrl() {
150+
assert_eq!(unctrl('\x1d'), ']');
151+
assert_eq!(unctrl_lower('\x1d'), ']');
152+
}
153+
150154
#[test]
151155
fn test_escape() {
152156
assert_eq!(escape_sequence("\x1b\x7f"), r"\e\C-?");

0 commit comments

Comments
 (0)