|
NAMEMIME::Words - deal with RFC 2047 encoded wordsSYNOPSISBefore 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::Words 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
Warning: this is a quick-and-dirty solution, intended for character sets which overlap ASCII. It does not comply with the RFC 2047 rules regarding the use of encoded words in message headers. You may want to roll your own variant, using "encode_mimeword()", for your application. Thanks to Jan Kasprzak for reminding me about this problem. SEE ALSOMIME::Base64, MIME::QuotedPrint, MIME::ToolsFor other implementations of this or similar functionality (particularly, ones with proper UTF8 support), see: Encode::MIME::Header, MIME::EncWords, MIME::AltWords At some future point, one of these implementations will likely replace MIME::Words and MIME::Words will become deprecated. NOTESExports its principle functions by default, in keeping with MIME::Base64 and MIME::QuotedPrint.AUTHOREryq (eryq@zeegee.com), ZeeGee Software Inc (http://www.zeegee.com). Dianne Skoll (dfs@roaringpenguin.com) http://www.roaringpenguin.comAll 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.
Visit the GSP FreeBSD Man Page Interface. |