Example usage for org.apache.commons.codec.net QuotedPrintableCodec encode

List of usage examples for org.apache.commons.codec.net QuotedPrintableCodec encode

Introduction

In this page you can find the example usage for org.apache.commons.codec.net QuotedPrintableCodec encode.

Prototype

public Object encode(Object pObject) throws EncoderException 

Source Link

Document

Encodes an object into its quoted-printable safe form.

Usage

From source file:mitm.common.template.QuotedPrintableEncodeMethod.java

@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
    if (arguments.size() != 1 && arguments.size() != 2) {
        throw new TemplateModelException(METHOD_NAME + " needs 1 or two arguments.");
    }/*from  w  w w .  j  a va2  s.co m*/
    try {
        String input = (String) arguments.get(0);

        String charset = arguments.size() == 2 ? (String) arguments.get(1) : CharacterEncoding.UTF_8;

        QuotedPrintableCodec codec = new QuotedPrintableCodec(charset);

        return new SimpleScalar(codec.encode(input));
    } catch (EncoderException e) {
        throw new TemplateModelException("Quoted Printable encoding failed", e);
    }
}

From source file:mail.MailService.java

/**
 * Konvertiert die bergebene Bytes in das Quoted printable Format.
 * @param input Die Originalbytes//  w  w w  .  j  a  va2  s  .co m
 * @return In Quoted Printable konvertierte Bytes.
 */
public byte[] encodeQuotedPrintable(byte[] input) {

    QuotedPrintableCodec qp = new QuotedPrintableCodec();

    return qp.encode(input);
}

From source file:org.jivesoftware.community.util.StringUtils.java

public static String encodeVCard(String toEncode, boolean isQuotedPrintable) {
    if (toEncode == null)
        return toEncode;
    String quotedPrintable = toEncode.replace(";", "\\;");
    if (isQuotedPrintable) {
        QuotedPrintableCodec codec = new QuotedPrintableCodec();
        try {//w ww. j av  a 2s .  co  m
            quotedPrintable = codec.encode(quotedPrintable);
        } catch (EncoderException e) {
            throw new RuntimeException("Error encoding vcard", e);
        }
    }
    return quotedPrintable;
}

From source file:org.owasp.jbrofuzz.encode.EncoderHashCore.java

private static String encodeRfc1521(final String encodeText) {
    final QuotedPrintableCodec codec = new QuotedPrintableCodec();
    try {//from   ww  w.  ja v  a  2  s  .c  o  m
        return codec.encode(encodeText);
    } catch (final EncoderException e) {
        return "Error: Sting input cannot be decoded";
    }
}