MIME::QuotedPrint - Encoding and decoding of quoted-printable strings


NAME

MIME::QuotedPrint - Encoding and decoding of quoted-printable strings


SYNOPSIS

 use MIME::QuotedPrint;
 $encoded = encode_qp($decoded);
 $decoded = decode_qp($encoded);


DESCRIPTION

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)
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.

decode_qp($str);
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.

If you prefer not to import these routines into your namespace you can call them as:

  use MIME::QuotedPrint ();
  $encoded = MIME::QuotedPrint::encode($decoded);
  $decoded = MIME::QuotedPrint::decode($encoded);

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);
    $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
    print $encoded;


COPYRIGHT

Copyright 1995-1997,2002-2003 Gisle Aas.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


SEE ALSO

the MIME::Base64 manpage

 MIME::QuotedPrint - Encoding and decoding of quoted-printable strings