赞
踩
// 保证.conf文件为unicode
FILE* fpRead = _tfopen(PATH_CONF, _T("r+b"));
if(!fpRead){
FILE* fpWrite = _tfopen(PATH_CONF, _T("w+b"));
if(fpWrite){
char szFlag[] = {0xff, 0xfe};//unicode prefix
fwrite(szFlag, sizeof(char), 2, fpWrite);
fclose(fpWrite);
}
}else{
fclose(fpRead);
}
前面个两个字节指定编码格式:
ANSI: 无格式定义;
Unicode: 前两个字节为FFFE;
Unicode big endian: 前两字节为FEFF;
UTF-8: 前两字节为EFBB;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。