fix push() function on string

didn't hnadle variable length encoding of the utf8 correctly
This commit is contained in:
bunnie 2021-03-06 02:55:14 +08:00
parent cb0686803e
commit 161b1943eb

View file

@ -105,9 +105,9 @@ impl<const N: usize> String<N> {
},
_ => {
let mut data: [u8; 4] = [0; 4];
ch.encode_utf8(&mut data);
if self.len() + data.len() < self.bytes.len() {
for &c in data.iter() {
let subslice = ch.encode_utf8(&mut data);
if self.len() + subslice.len() < self.bytes.len() {
for c in subslice.bytes() {
self.bytes[self.len()] = c;
self.len += 1;
}