Skip to content

Commit 79b7fe2

Browse files
committed
objstrunicode: Implement iterator.
1 parent cdc020d commit 79b7fe2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

py/objstrunicode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
330330
mp_obj_str_it_t *self = self_in;
331331
GET_STR_DATA_LEN(self->str, str, len);
332332
if (self->cur < len) {
333-
mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true);
334-
self->cur += 1;
333+
const byte *cur = str + self->cur;
334+
const byte *end = utf8_next_char(str + self->cur);
335+
mp_obj_t o_out = mp_obj_new_str((const char*)cur, end - cur, true);
336+
self->cur += end - cur;
335337
return o_out;
336338
} else {
337339
return MP_OBJ_STOP_ITERATION;

0 commit comments

Comments
 (0)