25 # pragma GCC diagnostic error "-Wsign-conversion"
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
42 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
43 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1,
58 const unsigned char *p, *perr, *pend = (
const unsigned char *)
str +
length;
62 for (p = (
const unsigned char *)
str; p < pend; p++,
length--) {
65 if (
ELEM(
c, 0xfe, 0xff, 0x00)) {
72 if ((
c & 0xc0) != 0xc0) {
87 if ((*p & 0xc0) != 0x80) {
95 if ((
c & 0x3e) == 0) {
102 if (
c == 0xe0 && (*p & 0x20) == 0) {
109 if (*p == 0xa0 && *(p + 1) == 0x80) {
112 if (*p == 0xad && *(p + 1) == 0xbf) {
115 if (*p == 0xae && *(p + 1) == 0x80) {
118 if (*p == 0xaf && *(p + 1) == 0xbf) {
121 if (*p == 0xb0 && *(p + 1) == 0x80) {
124 if (*p == 0xbe && *(p + 1) == 0x80) {
127 if (*p == 0xbf && *(p + 1) == 0xbf) {
133 if (*p == 0xbf && *(p + 1) == 0xbe) {
136 if (*p == 0xbf && *(p + 1) == 0xbf) {
144 if (
c == 0xf0 && (*p & 0x30) == 0) {
151 if (
c == 0xf8 && (*p & 0x38) == 0) {
158 if (
c == 0xfc && (*p & 0x3c) == 0) {
168 if ((*p & 0xc0) != 0x80) {
178 return ((
const char *)perr - (
const char *)
str);
190 length -= (size_t)(bad_char + 1);
207 #define BLI_STR_UTF8_CPY(dst, src, maxncpy) \
210 while (*src != '\0' && (utf8_size = utf8_skip_data[*src]) < maxncpy) { \
211 maxncpy -= utf8_size; \
212 switch (utf8_size) { \
243 memset(dst, 0xff,
sizeof(*dst) * maxncpy);
259 memset(dst, 0xff,
sizeof(*dst) * maxncpy);
265 return (
size_t)(dst - r_dst);
268 #undef BLI_STR_UTF8_CPY
274 const wchar_t *__restrict
src,
275 const size_t maxncpy)
280 memset(dst, 0xff,
sizeof(*dst) * maxncpy);
282 while (*
src &&
len < maxncpy) {
307 const char *strc_orig = strc;
309 for (
len = 0; *strc;
len++) {
313 *r_len_bytes = (size_t)(strc - strc_orig);
326 const char *strc_orig = strc;
327 const char *strc_end = strc + maxlen;
331 if (!*strc || strc + step > strc_end) {
338 *r_len_bytes = (size_t)(strc - strc_orig);
349 const char *__restrict src_c,
350 const size_t maxncpy)
355 return wcslen(dst_w);
367 if (ucs >= 0xf0000 || (ucs >= 0xe000 && ucs < 0xf8ff) || (ucs >= 0x1f300 && ucs < 0x1fbff)) {
370 return mk_wcwidth(ucs);
375 return mk_wcswidth(pwcs, n);
399 return (columns < 0) ? 1 : columns;
409 #define UTF8_COMPUTE(Char, Mask, Len, Err) \
414 else if ((Char & 0xe0) == 0xc0) { \
418 else if ((Char & 0xf0) == 0xe0) { \
422 else if ((Char & 0xf8) == 0xf0) { \
426 else if ((Char & 0xfc) == 0xf8) { \
430 else if ((Char & 0xfe) == 0xfc) { \
440 #define UTF8_GET(Result, Chars, Count, Mask, Len, Err) \
441 (Result) = (Chars)[0] & (Mask); \
442 for ((Count) = 1; (Count) < (Len); ++(Count)) { \
443 if (((Chars)[(Count)] & 0xc0) != 0x80) { \
448 (Result) |= ((Chars)[(Count)] & 0x3f); \
457 const unsigned char c = (
unsigned char)*p;
469 const unsigned char c = (
unsigned char)*p;
485 const unsigned char c = (
unsigned char)*p;
498 size_t *__restrict index)
503 const unsigned char c = (
unsigned char)*(p += *index);
516 *index += (size_t)
len;
523 size_t *__restrict index)
536 #define UTF8_VARS_FROM_CHAR32(Char, First, Len) \
541 else if (Char < 0x800) { \
545 else if (Char < 0x10000) { \
549 else if (Char < 0x200000) { \
553 else if (Char < 0x4000000) { \
586 memset(outbuf, 0x0, outbuf_len);
590 for (
uint i =
len - 1; i > 0; i--) {
591 outbuf[i] = (
c & 0x3f) | 0x80;
594 outbuf[0] =
c | first;
600 const char *__restrict src_c,
601 const size_t maxncpy)
603 const size_t maxlen = maxncpy - 1;
609 memset(dst_w, 0xff,
sizeof(*dst_w) * maxncpy);
612 const size_t src_c_len = strlen(src_c);
613 const char *src_c_end = src_c + src_c_len;
615 while ((index < src_c_len) && (
len != maxlen)) {
623 index = (size_t)(src_c_next - src_c);
635 const char32_t *__restrict
src,
636 const size_t maxncpy)
641 memset(dst, 0xff,
sizeof(*dst) * maxncpy);
643 while (*
src &&
len < maxncpy) {
671 for (--p; p >= str_start; p--) {
672 if ((*p & 0xc0) != 0x80) {
685 if ((p < str_end) && (*p !=
'\0')) {
686 for (++p; p < str_end && (*p & 0xc0) == 0x80; p++) {
714 const bool from_right)
716 const size_t str_len = end ? (size_t)(end -
str) : strlen(
str);
724 *suf = (
char *)(
str + str_len);
728 from_right ? (*sep >
str) : ((*sep < end) && (**sep !=
'\0'));
731 size_t index_ofs = 0;
740 for (
const uint *d = delim; *d !=
'\0'; d++) {
744 *suf = (
char *)(
str + index);
746 return (
size_t)(*sep -
str);
763 int index = 0,
pos = 0;
774 while (
pos != index) {
783 int column = 0,
pos = 0;
SyclQueue void void * src
SyclQueue void void size_t num_bytes void
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
T length(const vec_base< T, Size > &a)
#define UTF8_COMPUTE(Char, Mask, Len, Err)
ptrdiff_t BLI_str_utf8_invalid_byte(const char *str, size_t length)
int BLI_wcwidth(char32_t ucs)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy)
size_t BLI_str_utf8_from_unicode_len(const uint c)
size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy)
size_t BLI_strlen_utf8_ex(const char *strc, 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 BLI_str_partition_ex_utf8(const char *str, const char *end, const uint delim[], const char **sep, const char **suf, const bool from_right)
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen)
size_t BLI_str_utf32_as_utf8(char *__restrict dst, const char32_t *__restrict src, const size_t maxncpy)
int BLI_str_utf8_offset_from_column(const char *str, int column)
size_t BLI_strlen_utf8(const char *strc)
#define UTF8_VARS_FROM_CHAR32(Char, First, Len)
size_t BLI_str_utf32_as_utf8_len(const char32_t *src)
#define BLI_STR_UTF8_CPY(dst, src, maxncpy)
const char * BLI_str_find_next_char_utf8(const char *p, const char *str_end)
static const size_t utf8_skip_data[256]
const char * BLI_str_find_prev_char_utf8(const char *p, const char *str_start)
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy)
int BLI_str_utf8_offset_to_index(const char *str, int offset)
size_t BLI_str_partition_utf8(const char *str, const uint delim[], const char **sep, const char **suf)
size_t BLI_wstrlen_utf8(const wchar_t *src)
int BLI_str_utf8_char_width(const char *p)
size_t BLI_str_rpartition_utf8(const char *str, const uint delim[], const char **sep, const char **suf)
#define UTF8_GET(Result, Chars, Count, Mask, Len, Err)
int BLI_wcswidth(const char32_t *pwcs, size_t n)
int BLI_str_utf8_size(const char *p)
int BLI_str_utf8_invalid_strip(char *str, size_t length)
uint BLI_str_utf8_as_unicode(const char *p)
int BLI_str_utf8_size_safe(const char *p)
uint BLI_str_utf8_as_unicode_step(const char *__restrict p, const size_t p_len, size_t *__restrict index)
int BLI_str_utf8_offset_to_column(const char *str, int offset)
uint BLI_str_utf8_as_unicode_step_or_error(const char *__restrict p, const size_t p_len, size_t *__restrict index)
size_t BLI_str_utf8_from_unicode(uint c, char *outbuf, const size_t outbuf_len)
int BLI_str_utf8_char_width_safe(const char *p)
size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy)
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy)
int BLI_str_utf8_offset_from_index(const char *str, int index)
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)