如何以HTML格式将unicode复制到剪贴板?
因为英语有效,但如果我将不同的语言复制到剪贴板,它会变成这样:���
这是我的代码(copyStringEnd函数与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);
当我粘贴它时,它转向�