while( (len=stream.Read(buf,0,buf.Length)) != 0) { // 探测是否为Ascii编码 if (isAscii) isAscii = det.isAscii(buf,len); // 如果不是Ascii编码,并且编码未确定,则继续探测 if (!isAscii && !done) done = det.DoIt(buf,len, false); } stream.Close(); stream.Dispose(); //调用DatEnd方法, //如果引擎认为已经探测出了正确的编码, //则会在此时调用ICharsetDetectionObserver的Notify方法 det.DataEnd(); if (isAscii) { Console.WriteLine("CHARSET = ASCII"); found = true ; } else if (cdo.Charset != null) { Console.WriteLine("CHARSET = {0}",cdo.Charset); found = true; } if (!found) { string[] prob = det.getProbableCharsets() ; for(int i=0; i<prob.Length; i++) { Console.WriteLine("Probable Charset = " + prob[i]); } } Console.ReadLine(); http://www.cnblogs.com/hhh/archive/2007/01/27/632251.html |