public static Encoding GetFileEncoding(byte[] content)
{
if (content.Length > 0)
{
switch (content[0])
{
case 104:
return Encoding.Default;
case 255:
//有UTF-16,UTF-32
return Encoding.Unicode;
case 254:
return Encoding.BigEndianUnicode;
case 239:
return Encoding.UTF8;
case 43:
return Encoding.UTF7;
case 167:
//繁体下的ANSI
return Encoding.GetEncoding("BIG5");
case 196:
//简体下的ANSI
return Encoding.GetEncoding("GB2312");
default:
return Encoding.Default;
}
}
return Encoding.Default;
}
{
if (content.Length > 0)
{
switch (content[0])
{
case 104:
return Encoding.Default;
case 255:
//有UTF-16,UTF-32
return Encoding.Unicode;
case 254:
return Encoding.BigEndianUnicode;
case 239:
return Encoding.UTF8;
case 43:
return Encoding.UTF7;
case 167:
//繁体下的ANSI
return Encoding.GetEncoding("BIG5");
case 196:
//简体下的ANSI
return Encoding.GetEncoding("GB2312");
default:
return Encoding.Default;
}
}
return Encoding.Default;
}
id 博主 = [[KILONET.CNBLOGS.COM alloc] initWithValue:@"天堂向右,我依然向左"
网名:@"老舟"
兴趣:@"影音,阅读"
动态:@"系统架构设计,Android通信模块开发"
网址:@"http://kilonet.cnblogs.com"
签名:@"--------------------------------------------------
Stay Hungry , Stay Foolish
求 知 若 渴,处 事 若 愚
--------------------------------------------------"
]; // Never Release