How can I copy unicode to clipboard in HTML format?
Because english works, but if I copy a different language to clipboard, it turns like this: ���
Here is my code (copyStringEnd function is same as strcat):
char *html = "가나";//This is Korean
char *buf = (char*)malloc(400 + strlen(html));
strcpy_s(buf, 400,
"Version:0.9\r\n"
"StartHTML:00000000\r\n"
"EndHTML:00000000\r\n"
"StartFragment:00000000\r\n"
"EndFragment:00000000\r\n"
"<html><body>\r\n"
"<!--StartFragment -->\r\n");
copyStringEnd(buf, html);
copyStringEnd(buf, "\r\n");
copyStringEnd(buf,
"<!--EndFragment-->\r\n"
"</body>\r\n"
"</html>");
char *ptr = strstr(buf, "StartHTML");
wsprintf(ptr + 10, "%08u", strstr(buf, "<html>") - buf);
*(ptr + 10 + 8) = '\r';
ptr = strstr(buf, "EndHTML");
wsprintf(ptr + 8, "%08u", strlen(buf));
*(ptr + 8 + 8) = '\r';
ptr = strstr(buf, "StartFragment");
wsprintf(ptr + 14, "%08u", strstr(buf, "<!--StartFrag") - buf);
*(ptr + 14 + 8) = '\r';
ptr = strstr(buf, "EndFragment");
wsprintf(ptr + 12, "%08u", strstr(buf, "<!--EndFrag") - buf);
*(ptr + 12 + 8) = '\r';
if (OpenClipboard(NULL)) {
EmptyClipboard();
HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, strlen(buf) + 4);
char *ptrs = (char *)GlobalLock(hText);
strcpy_s(ptrs, strlen(buf) + 1, buf);
GlobalUnlock(hText);
SetClipboardData(RegisterClipboardFormat("HTML Format"), hText);
CloseClipboard();
GlobalFree(hText);
}
free(buf);
When i paste it it turns to �