fgets 读取中文乱码?
fp = fopen("rr.ini", "r");
char buf[128];
if (fp == NULL)
{
return FALSE;
}
int flag = 0;
while (!feof(fp))
{
flag++;
memset(buf,0,128);
fgets(buf, 128, fp);
CString strPath = Char2WChar(DelEnter(buf));
CString strReg("[reg]");
CString strRun("[run]");
CString strName("[name]");
if (strPath == strReg)
{
memset(buf, 0, 128);
fgets(buf, 128, fp);
strPath = Char2WChar(DelEnter(buf));
if (wcsncmp(strPath.Mid(0,7),_T("regname="),7) == 0)
{
strPath = strPath.Mid(8,strPath.GetLength());
if (strPath.GetLength() > 1)
{
m_ReadIniRegList=strPath;
}
m_ReadIniRegList=(L"null");
}
}
else
{
if (1 == flag)
{
m_ReadIniRegList=L"null";
}
}
if (strPath == strRun)
{
memset(buf, 0, 128);
fgets(buf, 128, fp);
strPath = Char2WChar(DelEnter(buf));
if (wcsncmp(strPath.Mid(0,6),_T("runexe="), 6) == 0)
{
strPath = strPath.Mid(7,strPath.GetLength());
m_ReadIniRunList=strPath;
}
else
{
m_ReadIniRunList = L"----";
}
}
if (strPath == strName)
{
memset(buf, '\0', 128);
fgets(buf, 128, fp); //此处读取的中文就会出现乱码(有的不会出现)
strPath = Char2WChar(DelEnter(buf));
if (wcsncmp(strPath.Mid(0,4),_T("name="), 4) == 0)
{
strPath = strPath.Mid(5,strPath.GetLength());
m_ReadIniNameList = strPath;
break;
}
else
{
m_ReadIniNameList = L"----";
}
}
}
fclose(fp);
相关推荐
fgets函数与fputs函数
文章简单介绍了fgets函数和fputs函数的应用及不同
php 读取文件乱码问题
网上的解决办法说抓取后用iconv()转码。看后我就觉 得不对劲:一个是不一定编译了iconv库,更大的问题是编码都跟流转换的时候有关(如果用了iconv实际上php转了两次码:流 -> UTF-8 -> GB2312):这不是白忙乎了吗? 仔细看了下php的文档(不知道大家都是怎么写代码的,其实文档上很清楚啊),上面关于fopen()及file_get_contents()都 提到了“默认是UTF-8,但是用户可以用stream_default_encoding()或者用户自定义上下文属性改变编码”(If unicode semantics are enabled, the default
matlab中读取txt数据文件方法.docx
.
php简单读取.vcf格式文件的方法示例
主要介绍了php简单读取.vcf格式文件的方法,结合具体实例形式分析了php自定义函数读取vcf格式文件的具体实现方法与相关注意事项,需要的朋友可以参考下
基于PHP读取csv文件内容的详解
一次性读取csv文件内所有行的数据复制代码 代码如下:<?php $file = fopen(‘windows_2011_s.csv’,’r’); while ($data = fgetcsv($file)) { //每次读取CSV里面的一行内容//print_r($data); //此为一个数组,要获得每一个数据,访问数组下标即可$goods_list[] = $data; }//print_r($goods_list);/* foreach ($goods_list as $arr){ if ($arr[0]!=””){ echo $arr[0].”<br>”;


