{
    "mode": "perldoc",
    "parameter": "MIME::Words",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/MIME%3A%3AWords/json",
    "generated": "2026-07-06T10:32:43Z",
    "synopsis": "Before reading further, you should see MIME::Tools to make sure that you understand where this\nmodule fits into the grand scheme of things. Go on, do it now. I'll wait.\nReady? Ok...\nuse MIME::Words qw(:all);\n### Decode the string into another string, forgetting the charsets:\n$decoded = decodemimewords(\n'To: =?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>',\n);\n### Split string into array of decoded [DATA,CHARSET] pairs:\n@decoded = decodemimewords(\n'To: =?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>',\n);\n### Encode a single unsafe word:\n$encoded = encodemimeword(\"\\xABFran\\xE7ois\\xBB\");\n### Encode a string, trying to find the unsafe words inside it:\n$encoded = encodemimewords(\"Me and \\xABFran\\xE7ois\\xBB in town\");",
    "sections": {
        "NAME": {
            "content": "MIME::Words - deal with RFC 2047 encoded words\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Before reading further, you should see MIME::Tools to make sure that you understand where this\nmodule fits into the grand scheme of things. Go on, do it now. I'll wait.\n\nReady? Ok...\n\nuse MIME::Words qw(:all);\n\n### Decode the string into another string, forgetting the charsets:\n$decoded = decodemimewords(\n'To: =?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>',\n);\n\n### Split string into array of decoded [DATA,CHARSET] pairs:\n@decoded = decodemimewords(\n'To: =?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>',\n);\n\n### Encode a single unsafe word:\n$encoded = encodemimeword(\"\\xABFran\\xE7ois\\xBB\");\n\n### Encode a string, trying to find the unsafe words inside it:\n$encoded = encodemimewords(\"Me and \\xABFran\\xE7ois\\xBB in town\");\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Fellow Americans, you probably won't know what the hell this module is for. Europeans, Russians,\net al, you probably do. \":-)\".\n\nFor example, here's a valid MIME header you might get:\n\nFrom: =?US-ASCII?Q?KeithMoore?= <moore@cs.utk.edu>\nTo: =?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>\nCC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>\nSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\n=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=\n=?US-ASCII?Q?..cool!?=\n\nThe fields basically decode to (sorry, I can only approximate the Latin characters with 7 bit\nsequences /o and 'e):\n\nFrom: Keith Moore <moore@cs.utk.edu>\nTo: Keld J/orn Simonsen <keld@dkuug.dk>\nCC: Andr'e  Pirard <PIRARD@vm1.ulg.ac.be>\nSubject: If you can read this you understand the example... cool!\n",
            "subsections": []
        },
        "PUBLIC INTERFACE": {
            "content": "decodemimewords ENCODED\n*Function.* Go through the string looking for RFC 2047-style \"Q\" (quoted-printable, sort of)\nor \"B\" (base64) encoding, and decode them.\n\nIn an array context, splits the ENCODED string into a list of decoded \"[DATA, CHARSET]\"\npairs, and returns that list. Unencoded data are returned in a 1-element array \"[DATA]\",\ngiving an effective CHARSET of \"undef\".\n\n$enc = '=?ISO-8859-1?Q?KeldJ=F8rnSimonsen?= <keld@dkuug.dk>';\nforeach (decodemimewords($enc)) {\nprint \"\", ($->[1] || 'US-ASCII'), \": \", $->[0], \"\\n\";\n}\n\nIn a scalar context, joins the \"data\" elements of the above list together, and returns that.\n*Warning: this is information-lossy,* and probably *not* what you want, but if you know that\nall charsets in the ENCODED string are identical, it might be useful to you. (Before you use\nthis, please see \"unmime\" in MIME::WordDecoder, which is probably what you want.)\n\nIn the event of a syntax error, $@ will be set to a description of the error, but parsing\nwill continue as best as possible (so as to get *something* back when decoding headers). $@\nwill be false if no error was detected.\n\nAny arguments past the ENCODED string are taken to define a hash of options:\n\nencodemimeword RAW, [ENCODING], [CHARSET]\n*Function.* Encode a single RAW \"word\" that has unsafe characters. The \"word\" will be\nencoded in its entirety.\n\n### Encode \"<<Franc,ois>>\":\n$encoded = encodemimeword(\"\\xABFran\\xE7ois\\xBB\");\n\nYou may specify the ENCODING (\"Q\" or \"B\"), which defaults to \"Q\". You may specify the\nCHARSET, which defaults to \"iso-8859-1\".\n\nencodemimewords RAW, [OPTS]\n*Function.* Given a RAW string, try to find and encode all \"unsafe\" sequences of characters:\n\n### Encode a string with some unsafe \"words\":\n$encoded = encodemimewords(\"Me and \\xABFran\\xE7ois\\xBB\");\n\nReturns the encoded string. Any arguments past the RAW string are taken to define a hash of\noptions:\n\nCharset\nEncode all unsafe stuff with this charset. Default is 'ISO-8859-1', a.k.a. \"Latin-1\".\n\nEncoding\nThe encoding to use, \"q\" or \"b\". The default is \"q\".\n\nWarning: this is a quick-and-dirty solution, intended for character sets which overlap\nASCII. It does not comply with the RFC 2047 rules regarding the use of encoded words in\nmessage headers. You may want to roll your own variant, using \"encodemimeword()\", for your\napplication. *Thanks to Jan Kasprzak for reminding me about this problem.*\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "MIME::Base64, MIME::QuotedPrint, MIME::Tools\n\nFor other implementations of this or similar functionality (particularly, ones with proper UTF8\nsupport), see:\n\nEncode::MIME::Header, MIME::EncWords, MIME::AltWords\n\nAt some future point, one of these implementations will likely replace MIME::Words and\nMIME::Words will become deprecated.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Exports its principle functions by default, in keeping with MIME::Base64 and MIME::QuotedPrint.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Eryq (eryq@zeegee.com), ZeeGee Software Inc (http://www.zeegee.com). Dianne Skoll\n(dfs@roaringpenguin.com) http://www.roaringpenguin.com\n\nAll rights reserved. This program is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n\nThanks also to...\n\nKent Boortz        For providing the idea, and the baseline\nRFC-1522-decoding code!\nKJJ at PrimeNet    For requesting that this be split into\nits own module.\nStephane Barizien  For reporting a nasty bug.\n",
            "subsections": []
        }
    },
    "summary": "MIME::Words - deal with RFC 2047 encoded words",
    "flags": [],
    "examples": [],
    "see_also": []
}