anticipate ansi encoding while parsing events
This commit is contained in:
+5
-1
@@ -176,7 +176,11 @@ macro_rules! parse_events_body {
|
||||
break;
|
||||
}
|
||||
|
||||
let line = $reader.get_line()?;
|
||||
let line = match $reader.get_line() {
|
||||
Ok(line) => line,
|
||||
Err(_) => $reader.get_line_ascii()?, // see ranked map id 49374
|
||||
};
|
||||
|
||||
let mut split = line.split(',');
|
||||
|
||||
// We're only interested in breaks
|
||||
|
||||
@@ -173,6 +173,17 @@ impl<R> FileReader<R> {
|
||||
.map_err(|e| ParseError::IoError(IoError::new(IoErrorKind::InvalidData, Box::new(e))))
|
||||
}
|
||||
|
||||
pub(crate) fn get_line_ascii(&mut self) -> Result<&str, ParseError> {
|
||||
self.buf.iter_mut().for_each(|byte| {
|
||||
if *byte >= 128 {
|
||||
*byte = b'?';
|
||||
}
|
||||
});
|
||||
|
||||
std::str::from_utf8(&self.buf)
|
||||
.map_err(|e| ParseError::IoError(IoError::new(IoErrorKind::InvalidData, Box::new(e))))
|
||||
}
|
||||
|
||||
/// Split the buffer at the first ':', then parse the second half into a string.
|
||||
///
|
||||
/// Returns `None` if there is no ':' or if the second half is invalid UTF-8.
|
||||
|
||||
Reference in New Issue
Block a user