#decode #encode #quoted #printable

quoted_printable

A simple encoder/decoder for quoted-printable data

10 releases

✓ Uses Rust 2018 edition

0.4.2 Feb 10, 2020
0.4.1 May 24, 2019
0.4.0 Sep 20, 2017
0.3.3 Sep 12, 2017
0.1.1 May 29, 2016

#4 in #encode

Download history 733/week @ 2019-12-02 1235/week @ 2019-12-09 1241/week @ 2019-12-16 1157/week @ 2019-12-23 1393/week @ 2019-12-30 1123/week @ 2020-01-06 1101/week @ 2020-01-13 1375/week @ 2020-01-20 1203/week @ 2020-01-27 1437/week @ 2020-02-03 1587/week @ 2020-02-10 1396/week @ 2020-02-17 1628/week @ 2020-02-24 1083/week @ 2020-03-02 1013/week @ 2020-03-09 989/week @ 2020-03-16

4,769 downloads per month
Used in 29 crates (4 directly)

0BSD license

23KB
433 lines

quoted-printable

Build Status Crate

A quoted-printable decoder and encoder.

API

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)

Documentation

See document on https://docs.rs.

No runtime deps