{"record":{"id":"e9118215c05d1e86","repo":"uutils/coreutils","slug":"invaliddata","errorCode":"InvalidData","errorMessage":"stream did not contain valid UTF-8","messagePattern":"stream did not contain valid UTF-8","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src/uu/csplit/src/csplit.rs","lineNumber":90,"sourceCode":"    }\n}\n\npub struct LinesWithNewlines<T: BufRead> {\n    inner: T,\n}\n\nimpl<T: BufRead> LinesWithNewlines<T> {\n    fn new(s: T) -> Self {\n        Self { inner: s }\n    }\n}\n\nimpl<T: BufRead> Iterator for LinesWithNewlines<T> {\n    type Item = io::Result<String>;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        fn ret(v: Vec<u8>) -> io::Result<String> {\n            String::from_utf8(v).map_err(|_| {\n                io::Error::new(ErrorKind::InvalidData, translate!(\"csplit-stream-not-utf8\"))\n            })\n        }\n\n        let mut v = Vec::new();\n        match self.inner.read_until(b'\\n', &mut v) {\n            Ok(0) => None,\n            Ok(_) => Some(ret(v)),\n            Err(e) => Some(Err(e)),\n        }\n    }\n}\n\n/// Splits a file into severals according to the command line patterns.\n///\n/// # Errors\n///\n/// - [`io::Error`] if there is some problem reading/writing from/to a file.","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/uutils/coreutils/blob/9ff4114e82c8fb80420fd4fb6a319bd3227095e0/src/uu/csplit/src/csplit.rs#L72-L108","documentation":"Error \"stream did not contain valid UTF-8\" thrown in uutils/coreutils.","triggerScenarios":"Occurs when csplit reads input that is not valid UTF-8 while processing patterns or line content as text.","commonSituations":"Running csplit on binary files, files in a non-UTF-8 encoding (e.g. Latin-1, UTF-16), or corrupted text files.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9ff4114e82c8fb80420fd4fb6a319bd3227095e0","analyzedAt":"2026-08-19T21:43:27.871Z","contentChangedAt":"2026-08-19T21:43:27.871Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}