uutils/coreutils · error · std::io::Error
InvalidData
InvalidData
Error message
stream did not contain valid UTF-8
What it means
Error "stream did not contain valid UTF-8" thrown in uutils/coreutils.
Source
Thrown at src/uu/csplit/src/csplit.rs:90
}
}
pub struct LinesWithNewlines<T: BufRead> {
inner: T,
}
impl<T: BufRead> LinesWithNewlines<T> {
fn new(s: T) -> Self {
Self { inner: s }
}
}
impl<T: BufRead> Iterator for LinesWithNewlines<T> {
type Item = io::Result<String>;
fn next(&mut self) -> Option<Self::Item> {
fn ret(v: Vec<u8>) -> io::Result<String> {
String::from_utf8(v).map_err(|_| {
io::Error::new(ErrorKind::InvalidData, translate!("csplit-stream-not-utf8"))
})
}
let mut v = Vec::new();
match self.inner.read_until(b'\n', &mut v) {
Ok(0) => None,
Ok(_) => Some(ret(v)),
Err(e) => Some(Err(e)),
}
}
}
/// Splits a file into severals according to the command line patterns.
///
/// # Errors
///
/// - [`io::Error`] if there is some problem reading/writing from/to a file.View on GitHub (pinned to 9ff4114e82)
Solutions
- Ensure the input file is valid UTF-8, or convert it with iconv before processing.
- If arbitrary bytes are expected, read the stream as bytes instead of UTF-8 text.
When it happens
Trigger: Occurs when csplit reads input that is not valid UTF-8 while processing patterns or line content as text.
Common situations: Running csplit on binary files, files in a non-UTF-8 encoding (e.g. Latin-1, UTF-16), or corrupted text files.
AI-assisted analysis of uutils/coreutils@9ff4114e82 (2026-08-19).
Data as JSON: /api/errors/e9118215c05d1e86.
Report an issue: GitHub.