Commit 46d31e9c authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

unicode: Add utf8_ptr_to_index().

Useful when we have pointer to char inside string, but need to return char
index. (E.g. str.find()).
parent ded0fc77
......@@ -86,6 +86,17 @@ char *utf8_next_char(const char *s) {
return (char *)s;
machine_uint_t utf8_ptr_to_index(const char *s, const char *ptr) {
machine_uint_t i = 0;
while (ptr > s) {
if (!UTF8_IS_CONT(*--ptr)) {
return i;
uint unichar_charlen(const char *str, uint len)
uint charlen = 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment