--- name: MIME::QuotedPrint runtime: pp source: src/native/MIME/QuotedPrint/pp.rs --- ```{index} single: MIME::QuotedPrint; Perl module (pp runtime) ``` # MIME::QuotedPrint Native implementation of MIME::QuotedPrint Provides quoted-printable encoding and decoding functions compatible with Perl's MIME::QuotedPrint module (part of MIME::Base64 distribution). Since PetaPerl does not support XS, this module is implemented directly in Rust. # Functions ## encode_qp Encode a string using quoted-printable encoding (RFC 2045). Non-printable and high-bit characters are represented as `=XX`. An optional second argument specifies the EOL sequence for soft line breaks (default: "\n"). An optional third argument enables binary mode, encoding CR and LF as `=0D` and `=0A`. ```perl use MIME::QuotedPrint; my $encoded = encode_qp("Hello =World"); my $binary = encode_qp($data, "\n", 1); ``` ## decode_qp Decode a quoted-printable encoded string back to the original data. Soft line breaks (`=\n`) are removed, `=XX` sequences are decoded, and trailing whitespace before newlines is stripped. ```perl use MIME::QuotedPrint; my $decoded = decode_qp($encoded); ``` # Quoted-Printable Encoding Rules (RFC 2045) 1. Non-printable chars (0x00-0x1F except tab 0x09, and 0x7F-0xFF) become `=XX` 2. `=` always encodes as `=3D` 3. Lines must not exceed 76 characters; soft breaks `=\n` are inserted 4. Trailing whitespace before EOL must be encoded (`=20`, `=09`) 5. `$eol` parameter (default `"\n"`): replaces `\n` in output for soft breaks 6. `$eol = ""` means no soft breaks (binary mode for line breaks) 7. `$binmode = true`: encode `\n` as `=0A`, `\r` as `=0D`