-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unicode output does not roundtrip #105
Comments
Seems to be a problem with the reader since this works with no problems: let output = std::process::Command::new("echo").arg("∀").output().expect("1");
let l = std::str::from_utf8(&output.stdout).expect("2");
println!("echo: {}", l); |
I dug into this a bit more and I think the problem is with #[test]
fn test_expect_unicode() {
let f = io::Cursor::new("∀ melon\r\n");
let mut r = NBReader::new(f, None);
assert_eq!(
("∀ melon".to_string(), "\r\n".to_string()),
r.read_until(&ReadUntil::String("\r\n".to_string()))
.expect("cannot read line")
);
// check for EOF
match r.read_until(&ReadUntil::NBytes(10)) {
Ok(_) => panic!(),
Err(Error::EOF { .. }) => {}
Err(_) => panic!(),
}
} and this is because in fn read_into_buffer(&mut self) -> Result<(), Error> {
if self.eof {
return Ok(());
}
while let Ok(from_channel) = self.reader.try_recv() {
match from_channel {
Ok(PipedChar::Char(c)) => self.buffer.push(c as char),
Ok(PipedChar::EOF) => self.eof = true,
// this is just from experience, e.g. "sleep 5" returns the other error which
// most probably means that there is no stdout stream at all -> send EOF
// this only happens on Linux, not on OSX
Err(PipeError::IO(ref err)) => {
// For an explanation of why we use `raw_os_error` see:
// https://github.com/zhiburt/ptyprocess/commit/df003c8e3ff326f7d17bc723bc7c27c50495bb62
self.eof = err.raw_os_error() == Some(5)
}
}
}
Ok(())
} This is done because the type of This behaviour is divergent from pexpect. I have 3 solutions to it:
|
Running into this issue now also. Would be lovely to see the MR merged :) |
sadly the authors seem to be inactive |
When I put the unicode character "∀" into
cat
, the output doesn't roundtrip:Code:
The text was updated successfully, but these errors were encountered: