private static void assertEncoded(String clearText, String encoded) throws Exception { byte[] expected = clearText.getBytes(US_ASCII_CHARSET); ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length()); byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET); QuotedPrintableDecoder.decode(encodedData, out); byte[] actual = out.toByteArray(); assertArrayEquals(expected, actual); }
int c1 = hexToBinary(b1); int c2 = hexToBinary(b2); out.write((c1 << UPPER_NIBBLE_SHIFT) | c2);
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out); } else { throw new UnsupportedEncodingException("Unknown RFC 2047 encoding: " + encoding);
int c1 = hexToBinary(b1); int c2 = hexToBinary(b2); out.write((c1 << UPPER_NIBBLE_SHIFT) | c2);
private static void assertIOException(String messageText, String encoded) throws UnsupportedEncodingException { ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length()); byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET); try { QuotedPrintableDecoder.decode(encodedData, out); fail("Expected IOException"); } catch (IOException e) { String em = e.getMessage(); assertTrue("Expected to find " + messageText + " in '" + em + "'",em.contains(messageText)); } }
int c1 = hexToBinary(b1); int c2 = hexToBinary(b2); out.write((c1 << UPPER_NIBBLE_SHIFT) | c2);
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out); } else { throw new UnsupportedEncodingException("Unknown RFC 2047 encoding: " + encoding);
Base64Decoder.decode(encodedData, out); } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable. QuotedPrintableDecoder.decode(encodedData, out); } else { throw new UnsupportedEncodingException("Unknown RFC 2047 encoding: " + encoding);