@Test public void testDecodeWithNullArray() throws Exception { final byte[] plain = null; final byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain ); assertEquals("Result should be null", null, result); }
public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { buffer.write(b); } } return buffer.toByteArray(); }
QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { buffer.write(b); } } return buffer.toByteArray(); } }
QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { buffer.write(b); } } return buffer.toByteArray(); } QuotedPrintableCodec();  QuotedPrintableCodec(final boolean strict);  QuotedPrintableCodec(final Charset charset);  QuotedPrintableCodec(final Charset charset, final boolean strict);  QuotedPrintableCodec(final String charsetName); }
QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { buffer.write(b); } } return buffer.toByteArray(); } QuotedPrintableCodec();  QuotedPrintableCodec(final boolean strict);  QuotedPrintableCodec(final Charset charset);  QuotedPrintableCodec(final Charset charset, final boolean strict);  QuotedPrintableCodec(final String charsetName); static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes); static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes, boolean strict); static final byte[] decodeQuotedPrintable(final byte[] bytes); @Override byte[] encode(final byte[] bytes); @Override byte[] decode(final byte[] bytes); @Override String encode(final String str); String decode(final String str, final Charset charset); String decode(final String str, final String charset); @Override String decode(final String str); @Override Object encode(final Object obj); @Override Object decode(final Object obj); Charset getCharset(); String getDefaultCharset(); String encode(final String str, final Charset charset); String encode(final String str, final String charset); }
QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { buffer.write(b); } } return buffer.toByteArray(); } QuotedPrintableCodec();  QuotedPrintableCodec(final boolean strict);  QuotedPrintableCodec(final Charset charset);  QuotedPrintableCodec(final Charset charset, final boolean strict);  QuotedPrintableCodec(final String charsetName); static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes); static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes, boolean strict); static final byte[] decodeQuotedPrintable(final byte[] bytes); @Override byte[] encode(final byte[] bytes); @Override byte[] decode(final byte[] bytes); @Override String encode(final String str); String decode(final String str, final Charset charset); String decode(final String str, final String charset); @Override String decode(final String str); @Override Object encode(final Object obj); @Override Object decode(final Object obj); Charset getCharset(); String getDefaultCharset(); String encode(final String str, final Charset charset); String encode(final String str, final String charset);  }