diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-14 02:07:25 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-27 00:04:19 +0300 |
commit | 79b7fe2ee58c1ac46c2fcb74bea69f2810bced5b (patch) | |
tree | c2e65ad12b651e5dee19d560e0d962266ffa294a /py | |
parent | cdc020da4b3da88418e248b8b4bca2247d238923 (diff) | |
download | micropython-79b7fe2ee58c1ac46c2fcb74bea69f2810bced5b.tar.gz micropython-79b7fe2ee58c1ac46c2fcb74bea69f2810bced5b.zip |
objstrunicode: Implement iterator.
Diffstat (limited to 'py')
-rw-r--r-- | py/objstrunicode.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c index e6ca35acbf..d70b33f8fe 100644 --- a/py/objstrunicode.c +++ b/py/objstrunicode.c @@ -330,8 +330,10 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { mp_obj_str_it_t *self = self_in; GET_STR_DATA_LEN(self->str, str, len); if (self->cur < len) { - mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true); - self->cur += 1; + const byte *cur = str + self->cur; + const byte *end = utf8_next_char(str + self->cur); + mp_obj_t o_out = mp_obj_new_str((const char*)cur, end - cur, true); + self->cur += end - cur; return o_out; } else { return MP_OBJ_STOP_ITERATION; |