string filename = “c://Default.asp”;
ifstream fin( filename.c_str(),ios::binary);
if( !fin )
{
cout << “打开文件” << filename << “出错” << endl;
//exit(-1);
}
else
{
byte bytes[3];
fin.read((char *)&bytes,sizeof bytes);
if(bytes[0] == 0xEF&& bytes[1] == 0xBB && bytes[2] == 0xBF)
{
cout <<”UTF8″<<endl;
}else
{
cout <<”GB2312″<<endl;
}
}
fin.close();
VC++ 判断文本文件是否UTF-8编码
最新推荐文章于 2024-06-12 23:15:18 发布