本文整理汇总了C#中Driver.setEncoding方法的典型用法代码示例。如果您正苦于以下问题:C# Driver.setEncoding方法的具体用法?C# Driver.setEncoding怎么用?C# Driver.setEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Driver
的用法示例。
在下文中一共展示了Driver.setEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlInputStreamReader
/**
* @param inputStream
* @param errorHandler
* @param locator
* @throws IOException
* @throws SAXException
*/
public HtmlInputStreamReader(Stream inputStream,
ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver,
Heuristics heuristics)
{
this.inputStream = inputStream;
this.errorHandler = errorHandler;
this.tokenizer = tokenizer;
this.driver = driver;
this.sniffing = true;
Encoding encoding = (new BomSniffer(this)).sniff();
if (encoding == null) {
position = 0;
encoding = (new MetaSniffer(errorHandler, this)).sniff(this);
if (encoding == null
&& (heuristics == Heuristics.CHARDET || heuristics == Heuristics.ALL)) {
encoding = (new ChardetSniffer(byteArray, limit)).sniff();
}
if (encoding == null
&& (heuristics == Heuristics.ICU || heuristics == Heuristics.ALL)) {
position = 0;
encoding = (new IcuDetectorSniffer(this)).sniff();
}
sniffing = false;
if (encoding == null) {
encoding = Encoding.WINDOWS1252;
}
if (driver != null) {
driver.setEncoding(encoding, Confidence.TENTATIVE);
}
} else {
if (encoding == Encoding.UTF8) {
if (driver != null) {
driver.setEncoding(Encoding.UTF8, Confidence.CERTAIN);
}
} else {
if (driver != null) {
driver.setEncoding(Encoding.UTF16, Confidence.CERTAIN);
}
}
}
this.decoder = encoding.newDecoder();
sniffing = false;
position = 0;
bytesRead = 0;
byteBuffer.position(position);
byteBuffer.limit(limit);
initDecoder();
}