中文部分出现乱码

英豪伟业 2008-10-14 08:10:15
void OnInitStatus(void)
{
String^ filename = L"info.txt";
if(!System::IO::File::Exists(filename))
return;
System::IO::StreamReader^ sr = System::IO::File::OpenText(filename);
String^ line;
int count=0;
while((line=sr->ReadLine())!=nullptr)
{
MessageBox::Show(line);
count++;
}
sr->Close();
}
info.txt文件中的一行的内容为:“大中华区],”只能正确显示“[192.168.0.1]”
请问该如果转换?
vs2005(c++)
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
英豪伟业 2008-10-14
  • 打赏
  • 举报
回复
谢谢提醒,修改成以下就可以了,
void OnInitStatus(void)
{
String^ filename = L"info.txt";
if(!System::IO::File::Exists(filename))
return;
array<String^ >^ temp = System::IO::File::ReadAllLines(filename,System::Text::Encoding::Default);
int len=temp->Length;
for(int i=0;i<len;i++)
{
MessageBox::show(temp[i]->ToString());
}
}
英豪伟业 2008-10-14
  • 打赏
  • 举报
回复
需要一行一行的读取~
Gregorian 2008-10-14
  • 打赏
  • 举报
回复
OpenText() 只能读取UTF8的text

用File::ReadAllLines(fileName,Encoding.Default)代替一下应该就好了
英豪伟业 2008-10-14
  • 打赏
  • 举报
回复
info.txt文件中的一行的内容为:“大中华区“[192.168.0.1],”只能正确显示“[192.168.0.1]”

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧