wine中文乱码补丁尝试
==========
附
freetype.c gdi32.dll.so ==========
水平有限,望多多指教
欢迎提供更好的方法
==========
有些程序使用 lf.lfCharSet=0 lf.lfCharSet=1 ...造成乱码,之前见过论坛里补丁对lf.lfCharSet=0(ANSI_CHARSET)有效,对1,...无效。
==========
改dlls/gdi32/freetype.c中
代码: 全选
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)lf.lfCharSet, &csi, TCI_SRCCHARSET)) {
switch(lf.lfCharSet) {
case DEFAULT_CHARSET:
csi.fs.fsCsb[0] = 0;
break;
default:
FIXME("Untranslated charset %d\n", lf.lfCharSet);
csi.fs.fsCsb[0] = 0;
break;
}
}
代码: 全选
/* WINE_CUSTOM_CHARSET PATCH 0.2 wine_1.5.24 liuyc BEGIN */
/*README
* ENVIRONMENT VARIABLES
WINE_FORCE_CODEPAGE : 0:disable 1:GetACP others:directly set codepage
or
WINE_CUSTOM_CODEPAGE : 1:enable
WINE_CHARSET_XXXX : 0:disable 1:GetACP others:directly set codepage (XXXX = 0,1,2,3,...)
*REFERENCES http://www.winehq.org/pipermail/wine-patches/attachments/20081203/b4b7e84f/attachment-0001.pdf
* LICENSE
*the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
*This patch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*/
UINT forcecodepage = 0;
UINT customcodepage = 0;
char *env_wfdc = getenv("WINE_FORCE_CODEPAGE");
char *env_wcdc = getenv("WINE_CUSTOM_CODEPAGE");
if(env_wfdc != NULL) forcecodepage = atoi(env_wfdc);
if(env_wcdc != NULL) customcodepage = atoi(env_wcdc);
if (forcecodepage != 0) {
if (forcecodepage == 1) {
forcecodepage = GetACP();
FIXME("WINE_FORCE_CODEPAGE == 1, lf.lfCharSet == %d, using GetACP (%d)\n",lf.lfCharSet,forcecodepage);
} else FIXME("WINE_FORCE_CODEPAGE == %d, overriding lfCharSet(%d)\n",forcecodepage,lf.lfCharSet);
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)forcecodepage, &csi,TCI_SRCCODEPAGE)) {
FIXME("OMG. Even this hack doesn't work. Let's PRAY.\n");
csi.fs.fsCsb[0] = 0;
}
lf.lfCharSet = csi.ciCharset;
} else {
if (customcodepage == 1) {
UINT codepage = 0;
//char *env_wedc = (char *)malloc(18*sizeof(char));
char *env_wedc;
//memset(env_wedc,0,sizeof(env_wedc));
//sprintf(env_wedc,"WINE_CHARSET_%.4d",lf.lfCharSet);
asprintf(&env_wedc,"WINE_CHARSET_%d",lf.lfCharSet);
FIXME("%s\n",env_wedc);
char *env_wdc = getenv(env_wedc);
if(env_wdc != NULL) codepage = atoi(env_wdc);
if (codepage != 0) {
if (codepage == 1) {
codepage = GetACP();
FIXME("%s == 1, using GetACP (%d)\n",env_wedc,codepage);
} else FIXME("%s == %d, overriding lfCharSet\n",env_wedc,codepage);
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)codepage, &csi,TCI_SRCCODEPAGE)) {
FIXME("OMG. Even this hack doesn't work. Let's PRAY.\n");
csi.fs.fsCsb[0] = 0;
}
lf.lfCharSet = csi.ciCharset;
} else if(!TranslateCharsetInfo((DWORD*)(INT_PTR)lf.lfCharSet, &csi, TCI_SRCCHARSET)) {
switch(lf.lfCharSet) {
case DEFAULT_CHARSET:
csi.fs.fsCsb[0] = 0;
break;
default:
FIXME("Untranslated charset %d\n", lf.lfCharSet);
csi.fs.fsCsb[0] = 0;
break;
}
}
//free(env_wedc);
} else if(!TranslateCharsetInfo((DWORD*)(INT_PTR)lf.lfCharSet, &csi, TCI_SRCCHARSET)) {
switch(lf.lfCharSet) {
case DEFAULT_CHARSET:
csi.fs.fsCsb[0] = 0;
break;
default:
FIXME("Untranslated charset %d\n", lf.lfCharSet);
csi.fs.fsCsb[0] = 0;
break;
}
}
}
// WINE_CUSTOM_CHARSET PATCH 0.2 wine_1.5.24 liuyc END