From f56cde83eb3332123c5fe4362632709e92e31167 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 28 Feb 2017 21:12:46 +0100 Subject: Fix encoding issues with title field in native Windows file save dialog. We were neither using Unicode versions of the WinAPI function nor properly converting character encodings which resultet in garbled output in the title field in the best case and invalid SVG output in the worst case. Fixed bugs: - https://launchpad.net/bugs/576126 - https://launchpad.net/bugs/1627551 (bzr r15557) --- src/ui/dialog/filedialogimpl-win32.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 02d77cba1..d232a48e4 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1971,18 +1971,18 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc( if(dlgFont) SendMessage(pImpl->_title_edit, WM_SETFONT, (WPARAM)dlgFont, MAKELPARAM(FALSE, 0)); SetWindowPos(pImpl->_title_edit, NULL, rCB1.left-rROOT.left, rCB1.top+ydelta-rROOT.top, rCB1.right-rCB1.left, rCB1.bottom-rCB1.top, SWP_SHOWWINDOW|SWP_NOZORDER); - // TODO: make sure this works for Unicode - SetWindowText(pImpl->_title_edit, pImpl->myDocTitle.c_str()); + SetWindowTextW(pImpl->_title_edit, + (const wchar_t*)g_utf8_to_utf16(pImpl->myDocTitle.c_str(), -1, NULL, NULL, NULL)); } } break; case WM_DESTROY: { if(pImpl->_title_edit) { - int length = GetWindowTextLength(pImpl->_title_edit)+1; - char* temp_title = new char[length]; - GetWindowText(pImpl->_title_edit, temp_title, length); - pImpl->myDocTitle = temp_title; + int length = GetWindowTextLengthW(pImpl->_title_edit)+1; + wchar_t* temp_title = new wchar_t[length]; + GetWindowTextW(pImpl->_title_edit, temp_title, length); + pImpl->myDocTitle = g_utf16_to_utf8((gunichar2*)temp_title, -1, NULL, NULL, NULL); delete[] temp_title; DestroyWindow(pImpl->_title_label); pImpl->_title_label = NULL; -- cgit v1.2.3