diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-29 05:06:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-29 05:11:09 +0300 |
commit | 2f7258d618a2a38fc982a9e0d0d7dd3cbc95ab3a (patch) | |
tree | 845beb6fdbc7de1461788a7d4f01a73fe710d6a7 /source/blender/blenlib/intern/string_utf8.c | |
parent | 4256eeeec4ca3f476a4dbb9e10a35d4904f76373 (diff) |
Fix BLI_strncpy_wchar_from_utf8 result on Windows
This function was documented to return the length but returned an
error value for WIN32. While this doesn't cause any bugs at the moment,
it could cause problems in the future.
Oversight in 5496d8cd361385268316f91afa150e69b5345ab0.
Diffstat (limited to 'source/blender/blenlib/intern/string_utf8.c')
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 3a5e2713b76..b9ea538ff24 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -378,7 +378,9 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const size_t maxncpy) { #ifdef WIN32 - return conv_utf_8_to_16(src_c, dst_w, maxncpy); + conv_utf_8_to_16(src_c, dst_w, maxncpy); + /* NOTE: it would be more efficient to calculate the length as part of #conv_utf_8_to_16. */ + return wcslen(dst_w); #else return BLI_str_utf8_as_utf32((char32_t *)dst_w, src_c, maxncpy); #endif |