mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
py/unicode: Fix check for valid utf8 being stricter about contn chars.
This commit is contained in:
@@ -180,7 +180,7 @@ bool utf8_check(const byte *p, size_t len) {
|
||||
for (; p < end; p++) {
|
||||
byte c = *p;
|
||||
if (need) {
|
||||
if (c >= 0x80) {
|
||||
if (UTF8_IS_CONT(c)) {
|
||||
need--;
|
||||
} else {
|
||||
// mismatch
|
||||
|
||||
@@ -47,3 +47,7 @@ try:
|
||||
str(bytearray(b'ab\xc0a'), 'utf8')
|
||||
except UnicodeError:
|
||||
print('UnicodeError')
|
||||
try:
|
||||
str(b'\xf0\xe0\xed\xe8', 'utf8')
|
||||
except UnicodeError:
|
||||
print('UnicodeError')
|
||||
|
||||
Reference in New Issue
Block a user