parse_utf8_char() makes the assumption that at least four bytes or one UTF-8 glyph are still to read in the input.
This commit is contained in:
parent
5e336e10a1
commit
fa2e86a558
17
src/event.rs
17
src/event.rs
|
@ -315,12 +315,17 @@ fn parse_utf8_char<I>(c: u8, iter: &mut I) -> Result<char, Error>
|
||||||
bytes.push(c);
|
bytes.push(c);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
bytes.push(iter.next().unwrap().unwrap());
|
match iter.next() {
|
||||||
if let Ok(st) = str::from_utf8(bytes) {
|
Some(Ok(next)) => {
|
||||||
return Ok(st.chars().next().unwrap());
|
bytes.push(next);
|
||||||
}
|
if let Ok(st) = str::from_utf8(bytes) {
|
||||||
if bytes.len() >= 4 {
|
return Ok(st.chars().next().unwrap());
|
||||||
return error;
|
}
|
||||||
|
if bytes.len() >= 4 {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => return error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue