天堂向右,我依然向左

天下之大,虽离家千里,何处不可往!何事不可为!
生活之路,纵坎坷曲折,当奋斗不息,则精彩纷呈!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
        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;
        }
posted on 2009-07-23 14:02  老舟  阅读(177)  评论(0编辑  收藏  举报