Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-11-22 18:26:54 +0300
committermano-wii <germano.costa@ig.com.br>2019-11-22 18:27:34 +0300
commit177dfc6384b926dd19e3b7e98a995ccb4da9167c (patch)
tree865abe9f707bee039a506bfc17cb4cff218bd6c6 /source/blender/blenlib/BLI_string_utf8.h
parent1304cee920c5f01fd9f0474ea782db61ac031403 (diff)
Fix T71273: Bad encoding of utf-8 for Text objects
`BLI_strncpy_wchar_from_utf8` internally assumes `wchar_t` is 32 bits which is not the case on windows. The solution is to replace `wchar_t` with `char32_t`. Thanks to @robbott for compatibility on macOS. Differential Revision: https://developer.blender.org/D6198
Diffstat (limited to 'source/blender/blenlib/BLI_string_utf8.h')
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index 0cdd6e94610..1db4cdfecd6 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -26,6 +26,7 @@ extern "C" {
#endif
#include "BLI_compiler_attrs.h"
+#include "BLI_sys_types.h"
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy)
ATTR_NONNULL();
@@ -48,6 +49,13 @@ unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p,
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index)
ATTR_NONNULL();
size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf);
+size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w,
+ const char *__restrict src_c,
+ const size_t maxncpy) ATTR_NONNULL();
+size_t BLI_str_utf32_as_utf8(char *__restrict dst,
+ const char32_t *__restrict src,
+ const size_t maxncpy) ATTR_NONNULL();
+size_t BLI_str_utf32_as_utf8_len(const char32_t *src) ATTR_NONNULL();
char *BLI_str_find_prev_char_utf8(const char *str, const char *p) ATTR_NONNULL();
char *BLI_str_find_next_char_utf8(const char *p, const char *end) ATTR_NONNULL(1);
@@ -68,8 +76,8 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst,
const size_t maxcpy) ATTR_NONNULL();
/* count columns that character/string occupies, based on wcwidth.c */
-int BLI_wcwidth(wchar_t ucs);
-int BLI_wcswidth(const wchar_t *pwcs, size_t n) ATTR_NONNULL();
+int BLI_wcwidth(char32_t ucs);
+int BLI_wcswidth(const char32_t *pwcs, size_t n) ATTR_NONNULL();
/* warning, can return -1 on bad chars */
int BLI_str_utf8_char_width(const char *p) ATTR_NONNULL();
int BLI_str_utf8_char_width_safe(const char *p) ATTR_NONNULL();