35 #if MICROPY_PY_BUILTINS_STR_UNICODE 44 bool has_single_quote =
false;
45 bool has_double_quote =
false;
46 for (
const byte *s = str_data, *top = str_data + str_len; !has_double_quote && s < top; s++) {
48 has_single_quote =
true;
49 }
else if (*s ==
'"') {
50 has_double_quote =
true;
54 if (has_single_quote && !has_double_quote) {
58 const byte *s = str_data, *top = str_data + str_len;
63 if (ch == quote_char) {
65 }
else if (ch ==
'\\') {
67 }
else if (32 <= ch && ch <= 126) {
69 }
else if (ch ==
'\n') {
71 }
else if (ch ==
'\r') {
73 }
else if (ch ==
'\t') {
75 }
else if (ch < 0x100) {
77 }
else if (ch < 0x10000) {
95 mp_printf(print,
"%.*s", str_len, str_data);
97 uni_print_quoted(print, str_data, str_len);
105 return mp_obj_new_bool(str_len != 0);
121 size_t index_val =
mp_get_index(type, self_len, index, is_slice);
122 return self_data + index_val;
129 if (MP_OBJ_IS_SMALL_INT(index)) {
134 const byte *s, *top = self_data + self_len;
138 for (s = top - 1; i; --s) {
184 #if MICROPY_PY_BUILTINS_SLICE 192 const byte *pstart, *pstop;
203 pstop = self_data + self_len;
205 if (pstop < pstart) {
215 for (
char mask = 0x40; *s & mask; mask >>= 1) {
226 #if MICROPY_CPYTHON_COMPAT 235 #if MICROPY_PY_BUILTINS_STR_SPLITLINES 247 #if MICROPY_PY_BUILTINS_STR_PARTITION 251 #if MICROPY_PY_BUILTINS_STR_CENTER 270 .unary_op = uni_unary_op,
272 .subscr = str_subscr,
281 typedef struct _mp_obj_str_it_t {
291 if (self->cur < len) {
292 const byte *cur = str +
self->cur;
295 self->cur += end - cur;
304 mp_obj_str_it_t *o = (mp_obj_str_it_t*)iter_buf;
312 #endif // MICROPY_PY_BUILTINS_STR_UNICODE
mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
#define MP_DEFINE_CONST_DICT(dict_name, table_name)
NORETURN void mp_raise_NotImplementedError(const char *msg)
const mp_obj_type_t mp_type_TypeError
STATIC mp_obj_t str_it_iternext(mp_obj_t self_in)
#define MP_OBJ_IS_TYPE(o, t)
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt,...)
mp_obj_type_t * mp_obj_get_type(mp_const_obj_t o_in)
int mp_print_str(const mp_print_t *print, const char *str)
#define MP_OBJ_FROM_PTR(p)
const byte * str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len, mp_obj_t index, bool is_slice)
#define MP_OBJ_NEW_QSTR(qst)
const mp_obj_type_t mp_type_bytes
const byte * utf8_next_char(const byte *s)
#define MP_OBJ_SMALL_INT_VALUE(o)
mp_obj_t(* mp_fun_1_t)(mp_obj_t)
size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice)
#define MP_OBJ_NEW_SMALL_INT(small_int)
const mp_obj_type_t mp_type_polymorph_iter
const mp_obj_type_t mp_type_str
mp_obj_t mp_obj_new_str(const char *data, size_t len, bool make_qstr_if_not_already)
mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags)
bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value)
const mp_obj_type_t mp_type_type
const mp_obj_type_t mp_type_IndexError
void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len)
unichar utf8_get_char(const byte *s)
const mp_obj_type_t mp_type_slice
mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte *data, size_t len)
#define UTF8_IS_NONASCII(ch)
const char * mp_obj_get_type_str(mp_const_obj_t o_in)
void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step)
#define MP_OBJ_STOP_ITERATION
int mp_printf(const mp_print_t *print, const char *fmt,...)
STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf)
mp_uint_t unichar_charlen(const char *str, mp_uint_t len)
#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len)