.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MIME::EncWords 3pm" .TH MIME::EncWords 3pm "2016-07-25" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MIME::EncWords \- deal with RFC 2047 encoded words (improved) .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fIMIME::EncWords is aimed to be another implimentation of MIME::Words so that it will achieve more exact conformance with \&\s-1RFC 2047 \s0(formerly \s-1RFC 1522\s0) specifications. Additionally, it contains some improvements. Following synopsis and descriptions are inherited from its inspirer, then added descriptions on improvements (\f(BI**\fI) or changes and clarifications (\f(BI*\fI).\fR .PP Before reading further, you should see MIME::Tools to make sure that you understand where this module fits into the grand scheme of things. Go on, do it now. I'll wait. .PP Ready? Ok... .PP .Vb 1 \& use MIME::EncWords qw(:all); \& \& ### Decode the string into another string, forgetting the charsets: \& $decoded = decode_mimewords( \& \*(AqTo: =?ISO\-8859\-1?Q?Keld_J=F8rn_Simonsen?= \*(Aq, \& ); \& \& ### Split string into array of decoded [DATA,CHARSET] pairs: \& @decoded = decode_mimewords( \& \*(AqTo: =?ISO\-8859\-1?Q?Keld_J=F8rn_Simonsen?= \*(Aq, \& ); \& \& ### Encode a single unsafe word: \& $encoded = encode_mimeword("\exABFran\exE7ois\exBB"); \& \& ### Encode a string, trying to find the unsafe words inside it: \& $encoded = encode_mimewords("Me and \exABFran\exE7ois\exBB in town"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Fellow Americans, you probably won't know what the hell this module is for. Europeans, Russians, et al, you probably do. \f(CW\*(C`:\-)\*(C'\fR. .PP For example, here's a valid \s-1MIME\s0 header you might get: .PP .Vb 6 \& From: =?US\-ASCII?Q?Keith_Moore?= \& To: =?ISO\-8859\-1?Q?Keld_J=F8rn_Simonsen?= \& CC: =?ISO\-8859\-1?Q?Andr=E9_?= Pirard \& Subject: =?ISO\-8859\-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= \& =?ISO\-8859\-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= \& =?US\-ASCII?Q?.._cool!?= .Ve .PP The fields basically decode to (sorry, I can only approximate the Latin characters with 7 bit sequences /o and 'e): .PP .Vb 4 \& From: Keith Moore \& To: Keld J/orn Simonsen \& CC: Andr\*(Aqe Pirard \& Subject: If you can read this you understand the example... cool! .Ve .PP \&\fBSupplement\fR: Fellow Americans, Europeans, you probably won't know what the hell this module is for. East Asians, et al, you probably do. \&\f(CW\*(C`(^_^)\*(C'\fR. .PP For example, here's a valid \s-1MIME\s0 header you might get: .PP .Vb 2 \& Subject: =?EUC\-KR?B?sNTAuLinKGxhemluZXNzKSwgwvzB9ri7seIoaW1w?= \& =?EUC\-KR?B?YXRpZW5jZSksILGzuLgoaHVicmlzKQ==?= .Ve .PP The fields basically decode to (sorry, I cannot approximate the non-Latin multibyte characters with any 7 bit sequences): .PP .Vb 1 \& Subject: ???(laziness), ????(impatience), ??(hubris) .Ve .SH "PUBLIC INTERFACE" .IX Header "PUBLIC INTERFACE" .IP "decode_mimewords \s-1ENCODED,\s0 [\s-1OPTS...\s0]" 4 .IX Item "decode_mimewords ENCODED, [OPTS...]" \&\fIFunction.\fR Go through the string looking for \s-1RFC\s0 2047\-style \*(L"Q\*(R" (quoted-printable, sort of) or \*(L"B\*(R" (base64) encoding, and decode them. .Sp \&\fBIn an array context,\fR splits the \s-1ENCODED\s0 string into a list of decoded \&\f(CW\*(C`[DATA, CHARSET]\*(C'\fR pairs, and returns that list. Unencoded data are returned in a 1\-element array \f(CW\*(C`[DATA]\*(C'\fR, giving an effective \&\s-1CHARSET\s0 of \f(CW\*(C`undef\*(C'\fR. .Sp .Vb 4 \& $enc = \*(Aq=?ISO\-8859\-1?Q?Keld_J=F8rn_Simonsen?= \*(Aq; \& foreach (decode_mimewords($enc)) { \& print "", ($_[1] || \*(AqUS\-ASCII\*(Aq), ": ", $_[0], "\en"; \& } .Ve .Sp \&\fB**\fR However, adjacent encoded-words with same charset will be concatenated to handle multibyte sequences safely. .Sp \&\fB**\fR Language information defined by \s-1RFC2231,\s0 section 5 will be additonal third element, if any. .Sp \&\fB*\fR Whitespaces surrounding unencoded data will not be stripped so that compatibility with MIME::Words will be ensured. .Sp \&\fBIn a scalar context,\fR joins the \*(L"data\*(R" elements of the above list together, and returns that. \fIWarning: this is information-lossy,\fR and probably \fInot\fR what you want, but if you know that all charsets in the \s-1ENCODED\s0 string are identical, it might be useful to you. (Before you use this, please see \*(L"unmime\*(R" in MIME::WordDecoder, which is probably what you want.) \&\fB**\fR See also \*(L"Charset\*(R" option below. .Sp In the event of a syntax error, $@ will be set to a description of the error, but parsing will continue as best as possible (so as to get \fIsomething\fR back when decoding headers). $@ will be false if no error was detected. .Sp \&\fB*\fR Malformed encoded-words will be kept encoded. In this case $@ will be set. .Sp Any arguments past the \s-1ENCODED\s0 string are taken to define a hash of options. \&\fB**\fR When Unicode/multibyte support is disabled (see \*(L"\s-1USE_ENCODE\*(R"\s0 in MIME::Charset), these options will not have any effects. .RS 4 .IP "Charset \fB**\fR" 4 .IX Item "Charset **" Name of character set by which data elements in scalar context will be converted. The default is no conversion. If this option is specified as special value \f(CW"_UNICODE_"\fR, returned value will be Unicode string. .Sp \&\fBNote\fR: This feature is still information-lossy, \fIexcept\fR when \f(CW"_UNICODE_"\fR is specified. .IP "Detect7bit \fB**\fR" 4 .IX Item "Detect7bit **" Try to detect 7\-bit charset on unencoded portions. Default is \f(CW"YES"\fR. .IP "Mapping \fB**\fR" 4 .IX Item "Mapping **" In scalar context, specify mappings actually used for charset names. \&\f(CW"EXTENDED"\fR uses extended mappings. \&\f(CW"STANDARD"\fR uses standardized strict mappings. Default is \f(CW"EXTENDED"\fR. .RE .RS 4 .RE .IP "encode_mimeword \s-1RAW,\s0 [\s-1ENCODING\s0], [\s-1CHARSET\s0]" 4 .IX Item "encode_mimeword RAW, [ENCODING], [CHARSET]" \&\fIFunction.\fR Encode a single \s-1RAW \s0\*(L"word\*(R" that has unsafe characters. The \*(L"word\*(R" will be encoded in its entirety. .Sp .Vb 2 \& ### Encode "<>": \& $encoded = encode_mimeword("\exABFran\exE7ois\exBB"); .Ve .Sp You may specify the \s-1ENCODING \s0(\f(CW"Q"\fR or \f(CW"B"\fR), which defaults to \f(CW"Q"\fR. \&\fB**\fR You may also specify it as ``special'' value: \f(CW"S"\fR to choose shorter one of either \f(CW"Q"\fR or \f(CW"B"\fR. .Sp You may specify the \s-1CHARSET,\s0 which defaults to \f(CW\*(C`iso\-8859\-1\*(C'\fR. .Sp \&\fB*\fR Spaces will be escaped with ``_'' by \f(CW"Q"\fR encoding. .IP "encode_mimewords \s-1RAW,\s0 [\s-1OPTS\s0]" 4 .IX Item "encode_mimewords RAW, [OPTS]" \&\fIFunction.\fR Given a \s-1RAW\s0 string, try to find and encode all \*(L"unsafe\*(R" sequences of characters: .Sp .Vb 2 \& ### Encode a string with some unsafe "words": \& $encoded = encode_mimewords("Me and \exABFran\exE7ois\exBB"); .Ve .Sp Returns the encoded string. .Sp \&\fB**\fR \&\s-1RAW\s0 may be a Unicode string when Unicode/multibyte support is enabled (see \*(L"\s-1USE_ENCODE\*(R"\s0 in MIME::Charset). Furthermore, \s-1RAW\s0 may be a reference to that returned by \*(L"decode_mimewords\*(R" on array context. In latter case \*(L"Charset\*(R" option (see below) will be overridden (see also a note below). .Sp \&\fBNote\fR: \&\fB*\fR When \s-1RAW\s0 is an arrayref, adjacent encoded-words (i.e. elements having non-ASCII charset element) are concatenated. Then they are split taking care of character boundaries of multibyte sequences when Unicode/multibyte support is enabled. Portions for unencoded data should include surrounding whitespace(s), or they will be merged into adjoining encoded\-word(s). .Sp Any arguments past the \s-1RAW\s0 string are taken to define a hash of options: .RS 4 .IP "Charset" 4 .IX Item "Charset" Encode all unsafe stuff with this charset. Default is '\s-1ISO\-8859\-1\s0', a.k.a. \*(L"Latin\-1\*(R". .IP "Detect7bit \fB**\fR" 4 .IX Item "Detect7bit **" When \*(L"Encoding\*(R" option (see below) is specified as \f(CW"a"\fR and \*(L"Charset\*(R" option is unknown, try to detect 7\-bit charset on given \s-1RAW\s0 string. Default is \f(CW"YES"\fR. When Unicode/multibyte support is disabled, this option will not have any effects (see \*(L"\s-1USE_ENCODE\*(R"\s0 in MIME::Charset). .IP "Encoding" 4 .IX Item "Encoding" The encoding to use, \f(CW"q"\fR or \f(CW"b"\fR. \&\fB**\fR You may also specify ``special'' values: \f(CW"a"\fR will automatically choose recommended encoding to use (with charset conversion if alternative charset is recommended: see MIME::Charset); \&\f(CW"s"\fR will choose shorter one of either \f(CW"q"\fR or \f(CW"b"\fR. \&\fBNote\fR: \&\fB*\fR As of release 1.005, The default was changed from \f(CW"q"\fR (the default on MIME::Words) to \f(CW"a"\fR. .IP "Field" 4 .IX Item "Field" Name of the mail field this string will be used in. \&\fB**\fR Length of mail field name will be considered in the first line of encoded header. .IP "Folding \fB**\fR" 4 .IX Item "Folding **" A Sequence to fold encoded lines. The default is \f(CW"\en"\fR. If empty string \f(CW""\fR is specified, encoded-words exceeding line length (see \*(L"MaxLineLen\*(R" below) will be split by \s-1SPACE.\s0 .Sp \&\fBNote\fR: \&\fB*\fR Though \s-1RFC 5322 \s0(formerly \s-1RFC 2822\s0) states that the lines in Internet messages are delimited by \s-1CRLF \s0(\f(CW"\er\en"\fR), this module chose \s-1LF \s0(\f(CW"\en"\fR) as a default to keep backward compatibility. When you use the default, you might need converting newlines before encoded headers are thrown into session. .IP "Mapping \fB**\fR" 4 .IX Item "Mapping **" Specify mappings actually used for charset names. \&\f(CW"EXTENDED"\fR uses extended mappings. \&\f(CW"STANDARD"\fR uses standardized strict mappings. The default is \f(CW"EXTENDED"\fR. When Unicode/multibyte support is disabled, this option will not have any effects (see \*(L"\s-1USE_ENCODE\*(R"\s0 in MIME::Charset). .IP "MaxLineLen \fB**\fR" 4 .IX Item "MaxLineLen **" Maximum line length excluding newline. The default is 76. Negative value means unlimited line length (as of release 1.012.3). .IP "Minimal \fB**\fR" 4 .IX Item "Minimal **" Takes care of natural word separators (i.e. whitespaces) in the text to be encoded. If \f(CW"NO"\fR is specified, this module will encode whole text (if encoding needed) not regarding whitespaces; encoded-words exceeding line length will be split based only on their lengths. Default is \f(CW"YES"\fR by which minimal portions of text are encoded. If \f(CW"DISPNAME"\fR is specified, portions including special characters described in \s-1RFC5322 \s0(formerly \s-1RFC2822, RFC822\s0) address specification (section 3.4) are also encoded. This is useful for encoding display-name of address fields. .Sp \&\fBNote\fR: As of release 0.040, default has been changed to \f(CW"YES"\fR to ensure compatibility with MIME::Words. On earlier releases, this option was fixed to be \f(CW"NO"\fR. .Sp \&\fBNote\fR: \&\f(CW"DISPNAME"\fR option was introduced at release 1.012. .IP "Replacement \fB**\fR" 4 .IX Item "Replacement **" See \*(L"Error Handling\*(R" in MIME::Charset. .RE .RS 4 .RE .SS "Configuration Files \fB**\fP" .IX Subsection "Configuration Files **" Built-in defaults of option parameters for \*(L"decode_mimewords\*(R" (except 'Charset' option) and \&\*(L"encode_mimewords\*(R" can be overridden by configuration files: \&\fIMIME/Charset/Defaults.pm\fR and \fIMIME/EncWords/Defaults.pm\fR. For more details read \fIMIME/EncWords/Defaults.pm.sample\fR. .SH "VERSION" .IX Header "VERSION" Consult \f(CW$VERSION\fR variable. .PP Development versions of this module may be found at . .SH "SEE ALSO" .IX Header "SEE ALSO" MIME::Charset, MIME::Tools .SH "AUTHORS" .IX Header "AUTHORS" The original version of function \fIdecode_mimewords()\fR is derived from MIME::Words module that was written by: Eryq (\fIeryq@zeegee.com\fR), ZeeGee Software Inc (\fIhttp://www.zeegee.com\fR). David F. Skoll (dfs@roaringpenguin.com) http://www.roaringpenguin.com .PP Other stuff are rewritten or added by: Hatuka*nezumi \- \s-1IKEDA\s0 Soji . .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.