Examples of QuotedPrintableCodec


Examples of org.apache.commons.codec.net.QuotedPrintableCodec

  }
 
  @Test
  public void testQuotedPrintableEncoding_1() throws UnsupportedEncodingException {
    String text = "This is a string with no special characters.";
    QuotedPrintableCodec QPC = new QuotedPrintableCodec();
    String encodedText = QPC.encode(text, "UTF8");
    assertEquals(text, encodedText);
  }
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

  @Test
  public void testQuotedPrintableEncoding_2() throws UnsupportedEncodingException {
    String text = "This is a string with special characters 新中西里杨阿姨.";
    String expected = "This is a string with special characters =E6=96=B0=E4=B8=AD=E8=A5=BF=E9=87=8C=E6=9D=A8=E9=98=BF=E5=A7=A8.";
   
    QuotedPrintableCodec QPC = new QuotedPrintableCodec();
    String encodedText = QPC.encode(text, "UTF8");
    assertEquals(expected, encodedText);
  }
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

      if(charset == null) {
        charset = Charset.defaultCharset();
      }
     
      if(qpCodec == null) {
        qpCodec = new QuotedPrintableCodec();
      }
     
      String str2 = qpCodec.encode(str1, charset.name());
     
      if(forceEncodeQuotedPrintableSpaces) {
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

    assertEquals(expectedUnfoldedVCard, unfolded2);
   
    //Make sure the quoted-printable lines can be properly decoded
    BufferedReader r = new BufferedReader(new StringReader(unfolded2));
    String line;
    QuotedPrintableCodec codec = new QuotedPrintableCodec();
    while ((line = r.readLine()) != null){
      String split[] = line.split(":", 2);
      if (split[0].toUpperCase().contains("QUOTED-PRINTABLE")){
        codec.decode(split[1]);
        //It will throw an exception and fail the test if it cannot be decoded
      }
    }
  }
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

                                                }
                                        }
                                }
                                for (int k = 0; k < p.getAttachmentList().size(); k++) {
                                        InputStream is = p.getAttachmentList().get((k)).getInputStream();
                                        QuotedPrintableCodec qp = new QuotedPrintableCodec();
                                        // If "is" is not already buffered, wrap a BufferedInputStream
                                        // around it.
                                        if (!(is instanceof BufferedInputStream)) {
                                                is = new BufferedInputStream(is);
                                        }
                                        int c;
                                        StringBuilder sb = new StringBuilder();
                                        System.out.println("Message : ");
                                        while ((c = is.read()) != -1) {
                                                sb.append(c);
                                                System.out.write(c);
                                        }
                                        is.close();
                                        String decoded = qp.decode(sb.toString());
                                        logger.info("decode message is " + decoded);
                                        if (decoded.contains(contains)) {
                                                //found it
                                                messages[i].setFlag(Flags.Flag.DELETED, true);
                                                found++;
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

    /**
     * @return Decoded email body, null if decoding failed
     */
    private String getDecodedMessage() {
        String body = removeSoftLineBreaks(email.getBody());
        QuotedPrintableCodec codec = new QuotedPrintableCodec();
        try {
            return codec.decode(body);
        } catch (DecoderException e) {
            e.printStackTrace();
        }

        return null;
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

  }
 
  // Decode RFC 1521 MIME (Multipurpose Internet Mail Extensions)
  // Part One. Rules #3, #4, and #5 of the quoted-printable spec are not implemented yet
  private static String decodeRfc1521(final String decodeText) {
    final QuotedPrintableCodec codec = new QuotedPrintableCodec();
    try {
      return codec.decode(decodeText);
    } catch (final DecoderException e) {
      return "Error: RFC 1521 MIME value cannot be decoded...";
    }
  }
View Full Code Here

Examples of org.apache.commons.codec.net.QuotedPrintableCodec

  }
 
  // Encode RFC 1521 MIME (Multipurpose Internet Mail Extensions)
  // Part One. Rules #3, #4, and #5 of the quoted-printable spec are not implemented yet
  private static String encodeRfc1521(final String encodeText) {
    final QuotedPrintableCodec codec = new QuotedPrintableCodec();
    try {
      return codec.encode(encodeText);
    } catch (final EncoderException e) {
      return "Error: Sting input cannot be decoded";
    }
  }
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.