#decode #encode #quoted #printable


A simple encoder/decoder for quoted-printable data

8 releases

0.4.0 Sep 20, 2017
0.3.3 Sep 12, 2017
0.3.1 Jul 18, 2017
0.3.0 Jun 10, 2016
0.1.1 May 29, 2016

#25 in Email

Download history 1776/week @ 2018-12-20 92/week @ 2018-12-27 137/week @ 2019-01-03 127/week @ 2019-01-10 144/week @ 2019-01-17 126/week @ 2019-01-24 166/week @ 2019-01-31 119/week @ 2019-02-07 209/week @ 2019-02-14 185/week @ 2019-02-21 184/week @ 2019-02-28 216/week @ 2019-03-07 182/week @ 2019-03-14 226/week @ 2019-03-21 426/week @ 2019-03-28

115 downloads per month
Used in 17 crates (4 directly)

0BSD license

433 lines


Build Status Crate

A quoted-printable decoder and encoder.


quoted-printable exposes two functions at the moment:

    decode<R: AsRef<[u8]>>(input: R, mode: ParseMode) -> Result<Vec<u8>, QuotedPrintableError>
    encode<R: AsRef<[u8]>>(input: R) -> Vec<u8>

using R: AsRef<[u8]> means that you can pass in a variety of types, including: String, &String, &str, Vec<u8>, &Vec<u8>, &[u8], Box<[u8]>, Arc<[u8]>

The decode function can be used to convert a quoted-printable string into the decoded bytes, as per the description in IETF RFC 2045, section 6.7. The ParseMode option can be used to control whether the decoding is "strict" or "robust", as per the comments in that RFC. In general you should probably use "robust" decoding, as it will gracefully handle more malformed input.

The encode function obviously does the reverse, and converts a set of raw bytes into quoted-printable.

Additionally there is following helper function:

    encode_to_str<R: AsRef<[u8]>>(input: R) -> String

which takes advantage of the fact that the Vec<u8> returned by encode can only contain valid us-ascii and converts it to a String (using the unsafe String::from_utf8_unchecked)


See the rustdoc at http://staktrace.github.io/quoted-printable/target/doc/quoted_printable/.

Other notes

This is written by a newbie Rust programmer, so code may be non-idiomatic or suboptimal. Pull requests are welcome!

No runtime deps