utf-8 string length determined by strlen

This commit is contained in:
Holger Vogt 2019-12-22 22:22:19 +01:00
parent 52a65f0aac
commit 93eb6d1954
1 changed files with 3 additions and 2 deletions

View File

@ -617,9 +617,10 @@ StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
wchar_t *WBuffer = TMALLOC(wchar_t, sizeof(SBuffer));
/* for utf-8 the number of characters is not the number of bytes returned */
GetWindowTextW(hwnd, WBuffer, sizeof SBuffer - (sizeof CRLF - 1));
/* retrive here the number of bytes returned */
const int n_char_returned = WideCharToMultiByte(CP_UTF8, 0, WBuffer,
WideCharToMultiByte(CP_UTF8, 0, WBuffer,
-1, SBuffer, sizeof SBuffer - 1, NULL, NULL);
/* retrive here the number of bytes returned */
const int n_char_returned = (int)strlen(SBuffer);
tfree(WBuffer);
#endif
unsigned int n_char_prev_cmd;