请教:vc从尾部向上按字节读取文件,结果遇到中文就乱码,怎么解决?

flex680 flex680 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
int n = 1, nLines = 0;
BYTE c;

// 读5行内容
while (nLines < 5)
{
// 从文件尾向上移动指针
uPosition = file.Seek(-n, CFile::end);

// 到文件头了
if (uPosition == 0)
{
if (strRecord.GetLength() > 0)
{
strRecord.MakeReverse(); // 反向排列
strArrayBuffer.Add(strRecord);
}
break;
}

UINT len = file.Read(&c, 1); // 读一个字节

if (strLine == '\n')
{
n += 2;
nLines++;
strRecord.MakeReverse();
strArrayBuffer.Add(strRecord);
strRecord.Empty();
}
else
{
n++;
strRecord += (char)c;
}
}

结果读到中文的时候变成了其它的中文了,请问如何解决?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
flex680
VC/MFC 16,550 成员 421,606 内容