allow copsing unicode in wesnoth
this completes a previous commit which enabled pasting unicode.
This commit is contained in:
parent
d3017c45a7
commit
321166b869
1 changed files with 7 additions and 4 deletions
|
@ -436,15 +436,18 @@ void copy_to_clipboard(const std::string& text, const bool)
|
|||
++last;
|
||||
}
|
||||
|
||||
const HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, (str.size() + 1) * sizeof(TCHAR));
|
||||
utf16::string ustring = unicode_cast<utf16::string>(str);
|
||||
std::wstring wstr(ustring.begin(), ustring.end());
|
||||
|
||||
const HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, (wstr.size() + 1) * sizeof(wchar_t));
|
||||
if(hglb == NULL) {
|
||||
CloseClipboard();
|
||||
return;
|
||||
}
|
||||
char* const buffer = reinterpret_cast<char* const>(GlobalLock(hglb));
|
||||
strcpy(buffer, str.c_str());
|
||||
wchar_t* const buffer = reinterpret_cast<wchar_t* const>(GlobalLock(hglb));
|
||||
wcscpy(buffer, wstr.c_str());
|
||||
GlobalUnlock(hglb);
|
||||
SetClipboardData(CF_TEXT, hglb);
|
||||
SetClipboardData(CF_UNICODETEXT, hglb);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue