所以最好的办法将其转换为utf8. 下面是代码片断
while(true)
{
System.Windows.Forms.OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "cs file|*.cs|all file|*.*";
dialog.Multiselect = false;
if(dialog.ShowDialog(this) == DialogResult.OK)
{
string fileName = dialog.FileName;
System.IO.StreamReader sr = new System.IO.StreamReader(fileName ,System.Text.Encoding.GetEncoding(936));
string line = sr.ReadToEnd();
sr.Close();
System.IO.StreamWriter SW = new System.IO.StreamWriter(fileName ,false,System.Text.UTF8Encoding.UTF8);
if(line != null)
{
SW.Write(line);
}
SW.Close();
}
else
break;
}
{
System.Windows.Forms.OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "cs file|*.cs|all file|*.*";
dialog.Multiselect = false;
if(dialog.ShowDialog(this) == DialogResult.OK)
{
string fileName = dialog.FileName;
System.IO.StreamReader sr = new System.IO.StreamReader(fileName ,System.Text.Encoding.GetEncoding(936));
string line = sr.ReadToEnd();
sr.Close();
System.IO.StreamWriter SW = new System.IO.StreamWriter(fileName ,false,System.Text.UTF8Encoding.UTF8);
if(line != null)
{
SW.Write(line);
}
SW.Close();
}
else
break;
}
GB2312到UTF8转换相关转载
该博客内容为转载,转载链接指向关于GB2312到UTF8转换的网页https://www.cnblogs.com/SharkXu/archive/2006/06/26/GB2312ToUTF8.html ,涉及字符编码转换这一信息技术内容。
1759

被折叠的 条评论
为什么被折叠?



