diff --git a/src/plugin.c b/src/plugin.c index 7d459d6..fd3fa69 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -57,13 +57,14 @@ static void set_clipboard(char *text) { if (!OpenClipboard(ctx->hwnd)) return; EmptyClipboard(); - HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, strlen(text) + 1); + int len = MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR)); if (hData != NULL) { - char *data = (char *)GlobalLock(hData); + WCHAR *data = (WCHAR *)GlobalLock(hData); if (data != NULL) { - strcpy(data, text); + MultiByteToWideChar(CP_UTF8, 0, text, -1, data, len); GlobalUnlock(hData); - SetClipboardData(CF_TEXT, hData); + SetClipboardData(CF_UNICODETEXT, hData); } } CloseClipboard();