/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted * back to their original representation. * * @param str * URL safe string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
byte[] data = StringUtils.getBytesUsAscii(text.substring(from, to)); data = doDecoding(data); return new String(data, charset);
@Test public void testGetBytesUsAscii() throws UnsupportedEncodingException { final String charsetName = "US-ASCII"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); }
private InputStream streamDataUrl(String dataUrl) { int dataIndex = dataUrl.indexOf(','); String data = dataUrl.substring(dataIndex + 1); byte[] bytes; if (dataUrl.substring(0, dataIndex).endsWith(";base64")) { bytes = Base64.decodeBase64(data); } else { try { bytes = URLCodec.decodeUrl(StringUtils.getBytesUsAscii(data)); } catch (DecoderException e) { throw new IllegalArgumentException("Invalid data URL: \"" + dataUrl + "\".", e); } } return new ByteArrayInputStream(bytes); }
private InputStream streamDataUrl(String dataUrl) { int dataIndex = dataUrl.indexOf(','); String data = dataUrl.substring(dataIndex + 1); byte[] bytes; if (dataUrl.substring(0, dataIndex).endsWith(";base64")) { bytes = Base64.decodeBase64(data); } else { try { bytes = URLCodec.decodeUrl(org.apache.commons.codec.binary.StringUtils.getBytesUsAscii(data)); } catch (DecoderException e) { throw new IllegalArgumentException("Invalid data URL: \"" + dataUrl + "\".", e); } } return new ByteArrayInputStream(bytes); } }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted * back to their original representation. * * @param str * URL safe string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted * back to their original representation. * * @param str * URL safe string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted * back to their original representation. * * @param str * URL safe string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted * back to their original representation. * * @param str * URL safe string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }
/** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * quoted-printable string to convert into its original form * @param charset * the original string charset * @return original string * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String decode(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), charset); }