字符集编码检测

nsDetector det = new nsDetector(nsPSMDetector.ALL);
    nsICharsetDetectionObserver nsIC = new nsICharsetDetectionObserver() {
        String encod = "";
        public void Notify(String charset) {
            HtmlCharsetDetector.found = true;
            encod = charset;
            System.out.println("CHARSET = " + charset);
        }

        public String getEncoding() {
            System.out.println("获得编码:" + encod);
            return encod;
        }
    };

    det.Init(nsIC);


    det.DoIt(buf, buf.length, false);
    det.DataEnd();
    String encode = nsIC.getEncoding();




文章来自: 本站原创
引用通告地址: http://www.xd-tech.com.cn/blog/trackback.asp?tbID=33
Tags:
评论: 0 | 引用: 551 | 查看次数: 6856
发表评论
昵 称:
密 码: 游客发言不需要密码.
验证码:
内 容:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 100 字 | UBB代码 开启 | [img]标签 开启