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
|
@ -315,7 +315,9 @@ 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() {
|
||||||
|
Some(Ok(next)) => {
|
||||||
|
bytes.push(next);
|
||||||
if let Ok(st) = str::from_utf8(bytes) {
|
if let Ok(st) = str::from_utf8(bytes) {
|
||||||
return Ok(st.chars().next().unwrap());
|
return Ok(st.chars().next().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -323,6 +325,9 @@ fn parse_utf8_char<I>(c: u8, iter: &mut I) -> Result<char, Error>
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => return error,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue