Examples of dataEnd()


Examples of org.mozilla.intl.chardet.nsDetector.DataEnd()

        boolean isAscii = det.isAscii(bytes,bytes.length);
        // DoIt if non-ascii and not done yet.
        if (!isAscii)
            det.DoIt(bytes,bytes.length, false);
        charsets = det.getProbableCharsets();
        det.DataEnd();
       
        if (isAscii) return "ASCII";
        if (charsets.length == 0) return null;
        if (charsets.length == 1 && charsets[0].equals("nomatch")) return null;
       
View Full Code Here

Examples of org.mozilla.intl.chardet.nsDetector.DataEnd()

   
    public Encoding sniff() throws IOException {
        nsDetector detector = new nsDetector(nsPSMDetector.ALL);
        detector.Init(this);
        detector.DoIt(source, length, false);
        detector.DataEnd();
        if (returnValue != null && returnValue != Encoding.WINDOWS1252 && returnValue.isAsciiSuperset()) {
            return returnValue;
        } else {
            return null;
        }
View Full Code Here

Examples of org.mozilla.intl.chardet.nsDetector.DataEnd()

        if (isAscii) { isAscii = det.isAscii(buf, len); }
        if (!isAscii) {
          if (det.DoIt(buf, len, false)) { break; }
        }
      } while ((len = in.read(buf)) > 0);
      det.DataEnd();
      charset = observer.charset;
    }
    if (charset != null) { charset = supportedCharsetName(charset); }
    if (charset == null) { charset = UTF8; }
    return Pair.pair(
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        int nread;

        while ((nread = fis.read(buf)) > 0 && !detector.isDone()) {
            detector.handleData(buf, 0, nread);
        }
        detector.dataEnd();
        fis.close();

        encoding = detector.getDetectedCharset();
        detector.reset();
        if (encoding != null) {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

    resource.mark(MAX_CHARSET_READAHEAD);
    int len = resource.read(bbuffer, 0, MAX_CHARSET_READAHEAD);
    resource.reset();
    detector.handleData(bbuffer, 0, len);
    // (3)
    detector.dataEnd();
      // (4)
      charsetName = detector.getDetectedCharset();

      // (5)
      detector.reset();
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

  private static Charset charset(byte[] content, String encoding) {
    if (encoding == null) {
      UniversalDetector d = new UniversalDetector(null);
      d.handleData(content, 0, content.length);
      d.dataEnd();
      encoding = d.getDetectedCharset();
    }
    if (encoding == null) {
      return ISO_8859_1;
    }
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

    byte[] buf = new byte[4096];
    int nread;
    while ((nread = is.read(buf)) > 0 && !detector.isDone()) {
      detector.handleData(buf, 0, nread);
    }
    detector.dataEnd();
    return detector.getDetectedCharset();
  }

  public static String getDetectedEncoding(File file) throws IOException {
    if (file != null && file.isFile() && file.canRead()) {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

            UniversalDetector detector = new UniversalDetector(null);
            byte[] buf = new byte[4096];
            int nread;
            while ((nread = is.read(buf)) > 0 && !detector.isDone())
                detector.handleData(buf, 0, nread);
            detector.dataEnd();
            encoding = detector.getDetectedCharset();
        } catch (Exception e) {
            Stderr.p("EclipseIFileUtil.getDetectedEncodingFrom(IFile): " + e.getClass().getName() + ","
                    + e.getLocalizedMessage());
        } finally {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        UniversalDetector charsetDetector = new UniversalDetector(new CharsetListener() {
            public void report(String charset) {
            }
        });
        charsetDetector.handleData(data, 0, data.length);
        charsetDetector.dataEnd();
        return charsetDetector.getDetectedCharset();
    }

    private CharsetDetector() {}
}
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        int nread;
        while ((nread = fis.read(buf)) > 0 && !detector.isDone()) {
            detector.handleData(buf, 0, nread);
        }
        // Notify the detector of the end of data
        detector.dataEnd();

        // Get the detected encoding name
        String detectedEncoding = detector.getDetectedCharset();
        if (detectedEncoding != null) {
            LOG.info(String.format("The encoding of the file is %s", detectedEncoding));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.