diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-13 10:11:09 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-13 10:11:09 -0500 |
commit | 0cc8739ddeae110620316fab5225bf6e1787dd3d (patch) | |
tree | 558c646e3c092735ae7f85e767af020188682f12 | |
parent | 8dfc9648c161e11a0cebd22e44452413cf3f8788 (diff) | |
download | textmode-0cc8739ddeae110620316fab5225bf6e1787dd3d.tar.gz textmode-0cc8739ddeae110620316fab5225bf6e1787dd3d.zip |
try harder to make utf8 strings when requested
-rw-r--r-- | src/private.rs | 4 | ||||
-rw-r--r-- | tests/input.rs | 52 |
2 files changed, 16 insertions, 40 deletions
diff --git a/src/private.rs b/src/private.rs index 6bb37a9..0b5d2f2 100644 --- a/src/private.rs +++ b/src/private.rs @@ -65,9 +65,9 @@ pub trait Input { && !self.should_parse_special_keys() } 28..=31 => true, - 32..=126 => true, + 32..=126 => !self.should_parse_utf8(), 127 => !self.should_parse_special_keys(), - 128..=255 => true, + 128..=255 => !self.should_parse_utf8(), }) .collect(); if !prefix.is_empty() { diff --git a/tests/input.rs b/tests/input.rs index 79aaea7..b1607bf 100644 --- a/tests/input.rs +++ b/tests/input.rs @@ -144,44 +144,20 @@ fn run_input_test( } } else { if utf8 { - // assert_eq!( - // std::string::String::from_utf8(fixtures::read_line( - // &mut r - // )) - // .unwrap(), - // "Bytes([27]): [27]\r\n" - // ); - // assert_eq!( - // std::string::String::from_utf8(fixtures::read_line( - // &mut r - // )) - // .unwrap(), - // "String(\"[A\"): [91, 65]\r\n" - // ); - if meta { - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "Bytes([27]): [27]\r\n" - ); - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "String(\"[A\"): [91, 65]\r\n" - ); - } else { - assert_eq!( - std::string::String::from_utf8( - fixtures::read_line(&mut r) - ) - .unwrap(), - "Bytes([27, 91, 65]): [27, 91, 65]\r\n" - ); - } + assert_eq!( + std::string::String::from_utf8(fixtures::read_line( + &mut r + )) + .unwrap(), + "Bytes([27]): [27]\r\n" + ); + assert_eq!( + std::string::String::from_utf8(fixtures::read_line( + &mut r + )) + .unwrap(), + "String(\"[A\"): [91, 65]\r\n" + ); } else { if meta { assert_eq!( |