Examples of BOMDetection


Examples of freenet.client.filter.CharsetExtractor.BOMDetection

  public static String detectCharset(byte[] input, int length, FilterMIMEType handler, String maybeCharset) throws IOException {
    // Detect charset
    String charset = detectBOM(input, length);
    if((charset == null) && (handler.charsetExtractor != null)) {
      BOMDetection bom = handler.charsetExtractor.getCharsetByBOM(input, length);
      if(bom != null) {
        charset = bom.charset;
        if(charset != null) {
          // These detections are not firm, and can detect a family e.g. ASCII, EBCDIC,
          // so check with the full extractor.
View Full Code Here

Examples of freenet.client.filter.CharsetExtractor.BOMDetection

    InputStream inputStream = inputBucket.getInputStream();
    OutputStream outputStream = outputBucket.getOutputStream();
    // Detect with original charset.
    String detectedCharset = filter.getCharset(bytes, bytes.length, charset);
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" even when parsing with correct charset", charset.equalsIgnoreCase(detectedCharset));
    BOMDetection bom = filter.getCharsetByBOM(bytes, bytes.length);
    String bomCharset = detectedCharset = bom == null ? null : bom.charset;
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" or \""+family+"\" from getCharsetByBOM", detectedCharset == null || charset.equalsIgnoreCase(detectedCharset) || (family != null && family.equalsIgnoreCase(detectedCharset)));
    detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null);
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset.equalsIgnoreCase(detectedCharset));
    FilterStatus filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4oobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), null, null, null);
View Full Code Here

Examples of freenet.client.filter.CharsetExtractor.BOMDetection

    SimpleReadOnlyArrayBucket inputBucket = new SimpleReadOnlyArrayBucket(bytes);
    Bucket outputBucket = new ArrayBucket();
    InputStream inputStream = inputBucket.getInputStream();
    OutputStream outputStream = outputBucket.getOutputStream();
    String detectedCharset;
    BOMDetection bom = filter.getCharsetByBOM(bytes, bytes.length);
    String bomCharset = detectedCharset = bom == null ? null : bom.charset;
    assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from getCharsetByBOM", detectedCharset == null);
    detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null);
    assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset == null || "utf-8".equalsIgnoreCase(detectedCharset));
    try {
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.