Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
5048df0b
Commit
5048df0b
authored
Jun 14, 2014
by
Paul Sokolovsky
Browse files
objstr: find(), rfind(), index(): Make return value be unicode-aware.
parent
46d31e9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objstr.c
View file @
5048df0b
...
...
@@ -32,6 +32,7 @@
#include
"mpconfig.h"
#include
"nlr.h"
#include
"misc.h"
#include
"unicode.h"
#include
"qstr.h"
#include
"obj.h"
#include
"runtime0.h"
...
...
@@ -591,6 +592,11 @@ STATIC mp_obj_t str_finder(uint n_args, const mp_obj_t *args, machine_int_t dire
}
}
else
{
// found
#if MICROPY_PY_BUILTINS_STR_UNICODE
if
(
self_type
==
&
mp_type_str
)
{
return
MP_OBJ_NEW_SMALL_INT
(
utf8_ptr_to_index
(
haystack
,
p
));
}
#endif
return
MP_OBJ_NEW_SMALL_INT
(
p
-
haystack
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment