diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-19 19:56:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-19 19:56:49 +0400 |
commit | cd3b98c4faf7e4f7e54138bfbc2616aeeadc86af (patch) | |
tree | f9755f0307ab11bd3021411f716d4b38330fac52 /source/blender/blenlib/intern/string_utf8.c | |
parent | de26f5922022abb341b1a66b1d700ded259b9265 (diff) |
step over unicode characters with autocomplete (correctly this time).
Diffstat (limited to 'source/blender/blenlib/intern/string_utf8.c')
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 9e0f9197ca3..d802ad53e6a 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -433,6 +433,22 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t * return result; } +unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index) +{ + int i, mask = 0, len; + unsigned int result; + const unsigned char c = (unsigned char) *p; + + UTF8_COMPUTE (c, mask, len, -1); + if (len == -1) { + *index += 1; + return c; + } + UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); + *index += len; + return result; +} + /* another variant that steps over the index, * note, currently this also falls back to latin1 for text drawing. */ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index) |