1MIME::EncWords(3)     User Contributed Perl Documentation    MIME::EncWords(3)
2
3
4

NAME

6       MIME::EncWords - deal with RFC 2047 encoded words (improved)
7

SYNOPSIS

9       MIME::EncWords is aimed to be another implimentation of MIME::Words so
10       that it will achieve more exact conformance with RFC 2047 (formerly RFC
11       1522) specifications.  Additionally, it contains some improvements.
12       Following synopsis and descriptions are inherited from its inspirer,
13       then added descriptions on improvements (**) or changes and
14       clarifications (*).
15
16       Before reading further, you should see MIME::Tools to make sure that
17       you understand where this module fits into the grand scheme of things.
18       Go on, do it now.  I'll wait.
19
20       Ready?  Ok...
21
22           use MIME::EncWords qw(:all);
23
24           ### Decode the string into another string, forgetting the charsets:
25           $decoded = decode_mimewords(
26                 'To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>',
27                 );
28
29           ### Split string into array of decoded [DATA,CHARSET] pairs:
30           @decoded = decode_mimewords(
31                 'To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>',
32                 );
33
34           ### Encode a single unsafe word:
35           $encoded = encode_mimeword("\xABFran\xE7ois\xBB");
36
37           ### Encode a string, trying to find the unsafe words inside it:
38           $encoded = encode_mimewords("Me and \xABFran\xE7ois\xBB in town");
39

DESCRIPTION

41       Fellow Americans, you probably won't know what the hell this module is
42       for.  Europeans, Russians, et al, you probably do.  ":-)".
43
44       For example, here's a valid MIME header you might get:
45
46             From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
47             To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
48             CC: =?ISO-8859-1?Q?Andr=E9_?= Pirard <PIRARD@vm1.ulg.ac.be>
49             Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
50              =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
51              =?US-ASCII?Q?.._cool!?=
52
53       The fields basically decode to (sorry, I can only approximate the Latin
54       characters with 7 bit sequences /o and 'e):
55
56             From: Keith Moore <moore@cs.utk.edu>
57             To: Keld J/orn Simonsen <keld@dkuug.dk>
58             CC: Andr'e  Pirard <PIRARD@vm1.ulg.ac.be>
59             Subject: If you can read this you understand the example... cool!
60
61       Supplement: Fellow Americans, Europeans, you probably won't know what
62       the hell this module is for.  East Asians, et al, you probably do.
63       "(^_^)".
64
65       For example, here's a valid MIME header you might get:
66
67             Subject: =?EUC-KR?B?sNTAuLinKGxhemluZXNzKSwgwvzB9ri7seIoaW1w?=
68              =?EUC-KR?B?YXRpZW5jZSksILGzuLgoaHVicmlzKQ==?=
69
70       The fields basically decode to (sorry, I cannot approximate the non-
71       Latin multibyte characters with any 7 bit sequences):
72
73             Subject: ???(laziness), ????(impatience), ??(hubris)
74

PUBLIC INTERFACE

76       decode_mimewords ENCODED, [OPTS...]
77           Function.  Go through the string looking for RFC 2047-style "Q"
78           (quoted-printable, sort of) or "B" (base64) encoding, and decode
79           them.
80
81           In an array context, splits the ENCODED string into a list of
82           decoded "[DATA, CHARSET]" pairs, and returns that list.  Unencoded
83           data are returned in a 1-element array "[DATA]", giving an
84           effective CHARSET of "undef".
85
86               $enc = '=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>';
87               foreach (decode_mimewords($enc)) {
88                   print "", ($_[1] || 'US-ASCII'), ": ", $_[0], "\n";
89               }
90
91           ** However, adjacent encoded-words with same charset will be
92           concatenated to handle multibyte sequences safely.
93
94           ** Language information defined by RFC2231, section 5 will be
95           additonal third element, if any.
96
97           * Whitespaces surrounding unencoded data will not be stripped so
98           that compatibility with MIME::Words will be ensured.
99
100           In a scalar context, joins the "data" elements of the above list
101           together, and returns that.  Warning: this is information-lossy,
102           and probably not what you want, but if you know that all charsets
103           in the ENCODED string are identical, it might be useful to you.
104           (Before you use this, please see "unmime" in MIME::WordDecoder,
105           which is probably what you want.)  ** See also "Charset" option
106           below.
107
108           In the event of a syntax error, $@ will be set to a description of
109           the error, but parsing will continue as best as possible (so as to
110           get something back when decoding headers).  $@ will be false if no
111           error was detected.
112
113           * Malformed encoded-words will be kept encoded.  In this case $@
114           will be set.
115
116           Any arguments past the ENCODED string are taken to define a hash of
117           options.  ** When Unicode/multibyte support is disabled (see
118           "USE_ENCODE" in MIME::Charset), these options will not have any
119           effects.
120
121           Charset **
122               Name of character set by which data elements in scalar context
123               will be converted.  The default is no conversion.  If this
124               option is specified as special value "_UNICODE_", returned
125               value will be Unicode string.
126
127               Note: This feature is still information-lossy, except when
128               "_UNICODE_" is specified.
129
130           Detect7bit **
131               Try to detect 7-bit charset on unencoded portions.  Default is
132               "YES".
133
134           Mapping **
135               In scalar context, specify mappings actually used for charset
136               names.  "EXTENDED" uses extended mappings.  "STANDARD" uses
137               standardized strict mappings.  Default is "EXTENDED".
138
139       encode_mimeword RAW, [ENCODING], [CHARSET]
140           Function.  Encode a single RAW "word" that has unsafe characters.
141           The "word" will be encoded in its entirety.
142
143               ### Encode "<<Franc,ois>>":
144               $encoded = encode_mimeword("\xABFran\xE7ois\xBB");
145
146           You may specify the ENCODING ("Q" or "B"), which defaults to "Q".
147           ** You may also specify it as ``special'' value: "S" to choose
148           shorter one of either "Q" or "B".
149
150           You may specify the CHARSET, which defaults to "iso-8859-1".
151
152           * Spaces will be escaped with ``_'' by "Q" encoding.
153
154       encode_mimewords RAW, [OPTS]
155           Function.  Given a RAW string, try to find and encode all "unsafe"
156           sequences of characters:
157
158               ### Encode a string with some unsafe "words":
159               $encoded = encode_mimewords("Me and \xABFran\xE7ois\xBB");
160
161           Returns the encoded string.
162
163           ** RAW may be a Unicode string when Unicode/multibyte support is
164           enabled (see "USE_ENCODE" in MIME::Charset).  Furthermore, RAW may
165           be a reference to that returned by "decode_mimewords" on array
166           context.  In latter case "Charset" option (see below) will be
167           overridden (see also a note below).
168
169           Note: * When RAW is an arrayref, adjacent encoded-words (i.e.
170           elements having non-ASCII charset element) are concatenated.  Then
171           they are split taking care of character boundaries of multibyte
172           sequences when Unicode/multibyte support is enabled.  Portions for
173           unencoded data should include surrounding whitespace(s), or they
174           will be merged into adjoining encoded-word(s).
175
176           Any arguments past the RAW string are taken to define a hash of
177           options:
178
179           Charset
180               Encode all unsafe stuff with this charset.  Default is
181               'ISO-8859-1', a.k.a. "Latin-1".
182
183           Detect7bit **
184               When "Encoding" option (see below) is specified as "a" and
185               "Charset" option is unknown, try to detect 7-bit charset on
186               given RAW string.  Default is "YES".  When Unicode/multibyte
187               support is disabled, this option will not have any effects (see
188               "USE_ENCODE" in MIME::Charset).
189
190           Encoding
191               The encoding to use, "q" or "b".  ** You may also specify
192               ``special'' values: "a" will automatically choose recommended
193               encoding to use (with charset conversion if alternative charset
194               is recommended: see MIME::Charset); "s" will choose shorter one
195               of either "q" or "b".  Note: * As of release 1.005, The default
196               was changed from "q" (the default on MIME::Words) to "a".
197
198           Field
199               Name of the mail field this string will be used in.  ** Length
200               of mail field name will be considered in the first line of
201               encoded header.
202
203           Folding **
204               A Sequence to fold encoded lines.  The default is "\n".  If
205               empty string "" is specified, encoded-words exceeding line
206               length (see "MaxLineLen" below) will be split by SPACE.
207
208               Note: * Though RFC 5322 (formerly RFC 2822) states that the
209               lines in Internet messages are delimited by CRLF ("\r\n"), this
210               module chose LF ("\n") as a default to keep backward
211               compatibility.  When you use the default, you might need
212               converting newlines before encoded headers are thrown into
213               session.
214
215           Mapping **
216               Specify mappings actually used for charset names.  "EXTENDED"
217               uses extended mappings.  "STANDARD" uses standardized strict
218               mappings.  The default is "EXTENDED".  When Unicode/multibyte
219               support is disabled, this option will not have any effects (see
220               "USE_ENCODE" in MIME::Charset).
221
222           MaxLineLen **
223               Maximum line length excluding newline.  The default is 76.
224               Negative value means unlimited line length (as of release
225               1.012.3).
226
227           Minimal **
228               Takes care of natural word separators (i.e. whitespaces) in the
229               text to be encoded.  If "NO" is specified, this module will
230               encode whole text (if encoding needed) not regarding
231               whitespaces; encoded-words exceeding line length will be split
232               based only on their lengths.  Default is "YES" by which minimal
233               portions of text are encoded.  If "DISPNAME" is specified,
234               portions including special characters described in RFC5322
235               (formerly RFC2822, RFC822) address specification (section 3.4)
236               are also encoded.  This is useful for encoding display-name of
237               address fields.
238
239               Note: As of release 0.040, default has been changed to "YES" to
240               ensure compatibility with MIME::Words.  On earlier releases,
241               this option was fixed to be "NO".
242
243               Note: "DISPNAME" option was introduced at release 1.012.
244
245           Replacement **
246               See "Error Handling" in MIME::Charset.
247
248   Configuration Files **
249       Built-in defaults of option parameters for "decode_mimewords" (except
250       'Charset' option) and "encode_mimewords" can be overridden by
251       configuration files: MIME/Charset/Defaults.pm and
252       MIME/EncWords/Defaults.pm.  For more details read
253       MIME/EncWords/Defaults.pm.sample.
254

VERSION

256       Consult $VERSION variable.
257
258       Development versions of this module may be found at
259       <http://hatuka.nezumi.nu/repos/MIME-EncWords/>.
260

SEE ALSO

262       MIME::Charset, MIME::Tools
263

AUTHORS

265       The original version of function decode_mimewords() is derived from
266       MIME::Words module that was written by:
267           Eryq (eryq@zeegee.com), ZeeGee Software Inc
268       (http://www.zeegee.com).
269           David F. Skoll (dfs@roaringpenguin.com)
270       http://www.roaringpenguin.com
271
272       Other stuff are rewritten or added by:
273           Hatuka*nezumi - IKEDA Soji <hatuka(at)nezumi.nu>.
274
275       This program is free software; you can redistribute it and/or modify it
276       under the same terms as Perl itself.
277
278
279
280perl v5.28.1                      2014-09-27                 MIME::EncWords(3)
Impressum