py/objstr: Add check for valid UTF-8 when making a str from bytes.
This patch adds a function utf8_check() to check for a valid UTF-8 encoded string, and calls it when constructing a str from raw bytes. The feature is selectable at compile time via MICROPY_PY_BUILTINS_STR_UNICODE_CHECK and is enabled if unicode is enabled. It costs about 110 bytes on Thumb-2, 150 bytes on Xtensa and 170 bytes on x86-64.
This commit is contained in:
@@ -30,5 +30,6 @@
|
||||
#include "py/misc.h"
|
||||
|
||||
mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr);
|
||||
bool utf8_check(const byte *p, size_t len);
|
||||
|
||||
#endif // MICROPY_INCLUDED_PY_UNICODE_H
|
||||
|
||||
Reference in New Issue
Block a user