





use MIME::QuotedPrint;

$encoded = encode_qp($decoded);
$decoded = decode_qp($encoded);


This module provides functions to encode and decode strings into the Quoted-Printable encoding specified in RFC 2045 - MIME (Multipurpose Internet Mail Extensions). The Quoted-Printable encoding is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. Non-printable characters (as defined by english americans) are represented by a triplet consisting of the character "=" followed by two hexadecimal digits.

The following functions are provided:

encode_qp($str, $eol)

This function will return an encoded version of the string given as argument.

The second argument is the line ending sequence to use. It is optional and defaults to "\n". Every occurence of "\n" will be replaced with this string and it will also be used for additional "soft line breaks" to ensure that no line is longer than 76 characters. You might want to pass it as "\015\012" to produce data suitable external consumption. The string "\r\n" will produce the same result on many platforms, but not all.

An $eol of "" special. If passed no "soft line breaks" are introduced and any literal "\n" in the original data is encoded as well.


This function will return the plain text version of the string given as argument. The lines of the result will be "\n" terminated even it the $str argument contains "\r\n" terminated lines.


use MIME::QuotedPrint ();

Perl v5.6 and better allow extended Unicode characters in strings. Such strings cannot be encoded directly as the quoted-printable encoding is only defined for bytes. The solution is to use the Encode module to select the byte encoding you want. For example:

use MIME::QuotedPrint qw(encode_qp);
use Encode qw(encode);

print $encoded;


Copyright 1995-1997,2002-2003 Gisle Aas.
