|
NAMEMIME::AltWords - properly deal with RFC-1522 encoded wordsSYNOPSISThe Perl module MIME::AltWords is recommended for encoding and decoding MIME words (such as "=?ISO-8859-2?Q?_=E1ll_e=E1r?=") found in e-mail message headers (mostly Subject, From and To).MIME::AltWords is similar to MIME::Words in MIME::Tools, but it provides an alternate implementation that follows the MIME specification more carefully, and it is actually compatible with existing mail software (tested with Mutt, Pine, JavaMail and OpenWebmail). MIME::AltWords extends the functionality of MIME::Words (version 5.420) by adding more functions and more options to existing functions. The original interface is changed in an upward-compatible way. 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. Ready? Ok... use MIME::AltWords qw(:all); ### Decode the string into another string, forgetting the charsets: $decoded = decode_mimewords( 'To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>', ); ### Split string into array of decoded [DATA,CHARSET] pairs: @decoded = decode_mimewords( 'To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>', ); ### Encode a single unsafe word: $encoded = encode_mimeword("\xABFran\xE7ois\xBB"); ### Encode a string, trying to find the unsafe words inside it: $encoded = encode_mimewords("Me and \xABFran\xE7ois\xBB in town"); DESCRIPTIONFellow Americans, you probably won't know what the hell this module is for. Europeans, Russians, et al, you probably do. ":-)".For example, here's a valid MIME header you might get: From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk> CC: =?ISO-8859-1?Q?Andr=E9_?= Pirard <PIRARD@vm1.ulg.ac.be> Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= =?US-ASCII?Q?.._cool!?= The fields basically decode to (sorry, I can only approximate the Latin characters with 7 bit sequences /o and 'e): From: Keith Moore <moore@cs.utk.edu> To: Keld J/orn Simonsen <keld@dkuug.dk> CC: Andr'e Pirard <PIRARD@vm1.ulg.ac.be> Subject: If you can read this you understand the example... cool! PUBLIC INTERFACE
Note: this is a stable, tested, widely compatible solution. Strict compliance with RFC-1522 (regarding the use of encoded words in message headers), however, was not proven, but strings returned by this function work properly and identically with Mutt, Pine, JavaMail and OpenWebmail. The recommended way is to use this function instead of "encode_mimeword()" or "encode_mimewords" in MIME::Words.
NOTESExports its principle functions by default, in keeping with MIME::Base64 and MIME::QuotedPrint.Doesn't depend on MIME::Words or MIME::Tools. All the shared code is copied to MIME::AltWords0, which is bundled. See also <http://www.szszi.hu/wiki/Sympa4Patches> for the previous version of MIME::AltWords integrated into the Sympa 4 mailing list software. AUTHORMIME::AltWords was written by Péter Szabó (pts@fazekas.hu) in 2006, and it has been uploaded to CPAN on 2006-09-27.MIME::AltWords uses code from MIME::Words (in the file "lib/MIME/AltWords0.pm") and it uses documentation from MIME::Words (in the files "lib/MIME/AltWords0.pm" and "lib/MIME/AltWords.pm"). Here is the original author and copyright information for MIME::Words. Eryq (eryq@zeegee.com), ZeeGee Software Inc (http://www.zeegee.com). David F. Skoll (dfs@roaringpenguin.com) http://www.roaringpenguin.com All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Thanks also to... Kent Boortz For providing the idea, and the baseline RFC-1522-decoding code! KJJ at PrimeNet For requesting that this be split into its own module. Stephane Barizien For reporting a nasty bug. VERSIONSee $VERSION in "lib/MIME/AltWords.pm" .
Visit the GSP FreeBSD Man Page Interface. |