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:
authorRay Molenkamp <github@lazydodo.com>2021-01-27 00:57:17 +0300
committerRay Molenkamp <github@lazydodo.com>2021-01-27 00:57:17 +0300
commite41a8bfabe139b2fadb29665c9f00bf2283bed55 (patch)
tree155841edff8929b1e3b9a8ab450b12cc1221ebdb /source/blender/blenlib/intern
parentd096d9c4d686471b9de2a993b76f5bd9fef9cb78 (diff)
parent5496d8cd361385268316f91afa150e69b5345ab0 (diff)
Merge remote-tracking branch 'origin/blender-v2.92-release'
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/string_utf8.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index 0a723a623f0..a637a5f24e6 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -33,7 +33,9 @@
#include "BLI_utildefines.h"
#include "BLI_string_utf8.h" /* own include */
-
+#ifdef WIN32
+# include "utfconv.h"
+#endif
#ifdef __GNUC__
# pragma GCC diagnostic error "-Wsign-conversion"
#endif
@@ -393,38 +395,11 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w,
const char *__restrict src_c,
const size_t maxncpy)
{
- const size_t maxlen = maxncpy - 1;
- size_t len = 0;
-
- BLI_assert(maxncpy != 0);
-
-#ifdef DEBUG_STRSIZE
- memset(dst_w, 0xff, sizeof(*dst_w) * maxncpy);
+#ifdef WIN32
+ return conv_utf_8_to_16(src_c, dst_w, maxncpy);
+#else
+ return BLI_str_utf8_as_utf32((char32_t *)dst_w, src_c, maxncpy);
#endif
-
- while (*src_c && len != maxlen) {
- size_t step = 0;
- uint unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step);
- if (unicode != BLI_UTF8_ERR) {
- /* TODO: `wchar_t` type is an implementation-defined and may represent
- * 16-bit or 32-bit depending on operating system.
- * So the ideal would be to do the corresponding encoding.
- * But for now just assert that it has no conflicting use. */
- BLI_assert(step <= sizeof(wchar_t));
- *dst_w = (wchar_t)unicode;
- src_c += step;
- }
- else {
- *dst_w = '?';
- src_c = BLI_str_find_next_char_utf8(src_c, NULL);
- }
- dst_w++;
- len++;
- }
-
- *dst_w = 0;
-
- return len;
}
/* end wchar_t / utf8 functions */