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
This commit is contained in:
mano-wii
2019-11-22 12:26:54 -03:00
parent 1304cee920
commit 177dfc6384
16 changed files with 198 additions and 90 deletions

View File

@@ -20,11 +20,19 @@
#ifndef __WCWIDTH_H__
#define __WCWIDTH_H__
#include <wchar.h>
#ifndef __cplusplus
# if defined(__APPLE__)
/* The <uchar.h> standard header is missing on macOS. */
#include <stddef.h>
typedef unsigned int char32_t;
# else
# include <uchar.h>
# endif
#endif
int mk_wcwidth(wchar_t ucs);
int mk_wcswidth(const wchar_t *pwcs, size_t n);
int mk_wcwidth_cjk(wchar_t ucs);
int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n);
int mk_wcwidth(char32_t ucs);
int mk_wcswidth(const char32_t *pwcs, size_t n);
int mk_wcwidth_cjk(char32_t ucs);
int mk_wcswidth_cjk(const char32_t *pwcs, size_t n);
#endif