Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/string_utf8.c
| Context not available. | |||||
| strc += BLI_str_utf8_size_safe(strc); | strc += BLI_str_utf8_size_safe(strc); | ||||
| } | } | ||||
| *r_len_bytes = (size_t)(strc - strc_orig); | if (r_len_bytes) { | ||||
| *r_len_bytes = (size_t)(strc - strc_orig); | |||||
| } | |||||
| return len; | return len; | ||||
| } | } | ||||
| size_t BLI_strlen_utf8(const char *strc) | size_t BLI_strlen_utf8(const char *strc) | ||||
| { | { | ||||
| size_t len; | return BLI_strlen_utf8_ex(strc, NULL); | ||||
| for (len = 0; *strc; len++) { | |||||
| strc += BLI_str_utf8_size_safe(strc); | |||||
| } | |||||
| return len; | |||||
| } | } | ||||
| size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_bytes) | size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_bytes) | ||||
| { | { | ||||
| size_t len; | size_t len = 0; | ||||
| const char *strc_orig = strc; | const char *strc_orig = strc; | ||||
| const char *strc_end = strc + maxlen; | const char *strc_end = strc + maxlen; | ||||
| for (len = 0; *strc && strc < strc_end; len++) { | while (true) { | ||||
| strc += BLI_str_utf8_size_safe(strc); | size_t step = BLI_str_utf8_size_safe(strc); | ||||
| if (!*strc || strc + step > strc_end) { | |||||
| break; | |||||
| } | |||||
| strc += step; | |||||
| len++; | |||||
| } | } | ||||
| *r_len_bytes = (size_t)(strc - strc_orig); | if (r_len_bytes) { | ||||
| *r_len_bytes = (size_t)(strc - strc_orig); | |||||
| } | |||||
| return len; | return len; | ||||
| } | } | ||||
| Context not available. | |||||
| */ | */ | ||||
| size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) | size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) | ||||
| { | { | ||||
| size_t len; | return BLI_strnlen_utf8_ex(strc, maxlen, NULL); | ||||
| const char *strc_end = strc + maxlen; | |||||
| for (len = 0; *strc && strc < strc_end; len++) { | |||||
| strc += BLI_str_utf8_size_safe(strc); | |||||
| } | |||||
| return len; | |||||
| } | } | ||||
| size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, | size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, | ||||
| Context not available. | |||||