From dcfaebf9d9bc54a1a580572391d617ae472e442f Mon Sep 17 00:00:00 2001 From: Julian Schiedel Date: Wed, 15 Feb 2023 10:36:38 +0100 Subject: [PATCH] Replaced mbstowcs with mbstowcs_s to fix fix compiler warning about deprecation --- include/indicators/display_width.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/indicators/display_width.hpp b/include/indicators/display_width.hpp index e2cf159..c97a2ee 100644 --- a/include/indicators/display_width.hpp +++ b/include/indicators/display_width.hpp @@ -312,10 +312,10 @@ static inline int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n) { static inline std::wstring utf8_decode(const std::string &s) { std::string curLocale = setlocale(LC_ALL, ""); const char *_Source = s.c_str(); - size_t _Dsize = mbstowcs(NULL, _Source, 0) + 1; + size_t _Dsize = strlen(_Source) + 1; wchar_t *_Dest = new wchar_t[_Dsize]; - wmemset(_Dest, 0, _Dsize); - mbstowcs(_Dest, _Source, _Dsize); + size_t _Osize; + mbstowcs_s(&_Osize, _Dest, _Dsize, _Source, _Dsize); std::wstring result = _Dest; delete[] _Dest; setlocale(LC_ALL, curLocale.c_str());