From 2f7258d618a2a38fc982a9e0d0d7dd3cbc95ab3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Aug 2021 12:06:15 +1000 Subject: 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. --- source/blender/blenlib/intern/string_utf8.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3