1MIME::QuotedPrint(3pm) Perl Programmers Reference Guide MIME::QuotedPrint(3pm)
2
3
4

NAME

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

SYNOPSIS

9        use MIME::QuotedPrint;
10
11        $encoded = encode_qp($decoded);
12        $decoded = decode_qp($encoded);
13

DESCRIPTION

15       This module provides functions to encode and decode strings into and
16       from the quoted-printable encoding specified in RFC 2045 - MIME (Multi‐
17       purpose Internet Mail Extensions).  The quoted-printable encoding is
18       intended to represent data that largely consists of bytes that corre‐
19       spond to printable characters in the ASCII character set.  Each non-
20       printable character (as defined by English Americans) is represented by
21       a triplet consisting of the character "=" followed by two hexadecimal
22       digits.
23
24       The following functions are provided:
25
26       encode_qp($str)
27       encode_qp($str, $eol)
28       encode_qp($str, $eol, $binmode)
29           This function returns an encoded version of the string ($str) given
30           as argument.
31
32           The second argument ($eol) is the line-ending sequence to use.  It
33           is optional and defaults to "\n".  Every occurrence of "\n" is
34           replaced with this string, and it is also used for additional "soft
35           line breaks" to ensure that no line end up longer than 76 charac‐
36           ters.  Pass it as "\015\012" to produce data suitable for external
37           consumption.  The string "\r\n" produces the same result on many
38           platforms, but not all.
39
40           The third argument ($binmode) will select binary mode if passed as
41           a TRUE value.  In binary mode "\n" will be encoded in the same way
42           as any other non-printable character.  This ensures that a decoder
43           will end up with exactly the same string whatever line ending
44           sequence it uses.  In general it is preferable to use the base64
45           encoding for binary data; see MIME::Base64.
46
47           An $eol of "" (the empty string) is special.  In this case, no
48           "soft line breaks" are introduced and binary mode is effectively
49           enabled so that any "\n" in the original data is encoded as well.
50
51       decode_qp($str);
52           This function returns the plain text version of the string given as
53           argument.  The lines of the result are "\n" terminated, even if the
54           $str argument contains "\r\n" terminated lines.
55
56       If you prefer not to import these routines into your namespace, you can
57       call them as:
58
59         use MIME::QuotedPrint ();
60         $encoded = MIME::QuotedPrint::encode($decoded);
61         $decoded = MIME::QuotedPrint::decode($encoded);
62
63       Perl v5.8 and better allow extended Unicode characters in strings.
64       Such strings cannot be encoded directly, as the quoted-printable encod‐
65       ing is only defined for single-byte characters.  The solution is to use
66       the Encode module to select the byte encoding you want.  For example:
67
68           use MIME::QuotedPrint qw(encode_qp);
69           use Encode qw(encode);
70
71           $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
72           print $encoded;
73
75       Copyright 1995-1997,2002-2004 Gisle Aas.
76
77       This library is free software; you can redistribute it and/or modify it
78       under the same terms as Perl itself.
79

SEE ALSO

81       MIME::Base64
82
83
84
85perl v5.8.8                       2001-09-21            MIME::QuotedPrint(3pm)
Impressum