{
    "content": [
        {
            "type": "text",
            "text": "# Mail::Message::Body::Encode (perldoc)\n\n## NAME\n\nMail::Message::Body::Encode - organize general message encodings\n\n## SYNOPSIS\n\nmy Mail::Message $msg = ...;\nmy $decoded = $msg->decoded;\nmy $encoded = $msg->encode(mimetype => 'image/gif',\ntransferencoding => 'base64');\nmy $body = $msg->body;\nmy $decoded = $body->decoded;\nmy $encoded = $body->encode(transferencoding => '7bit');\n\n## DESCRIPTION\n\nManages the message's body encodings and decodings on request of the main program. This package\nadds functionality to the Mail::Message::Body class when the decoded() or encode() method is\ncalled.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS** (3 subsections)\n- **DIAGNOSTICS**\n- **SEE ALSO**\n- **LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Mail::Message::Body::Encode",
        "section": "",
        "mode": "perldoc",
        "summary": "Mail::Message::Body::Encode - organize general message encodings",
        "synopsis": "my Mail::Message $msg = ...;\nmy $decoded = $msg->decoded;\nmy $encoded = $msg->encode(mimetype => 'image/gif',\ntransferencoding => 'base64');\nmy $body = $msg->body;\nmy $decoded = $body->decoded;\nmy $encoded = $body->encode(transferencoding => '7bit');",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Constructing a body",
                        "lines": 54
                    },
                    {
                        "name": "About the payload",
                        "lines": 17
                    },
                    {
                        "name": "Internals",
                        "lines": 15
                    }
                ]
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Mail::Message::Body::Encode - organize general message encodings\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "my Mail::Message $msg = ...;\nmy $decoded = $msg->decoded;\nmy $encoded = $msg->encode(mimetype => 'image/gif',\ntransferencoding => 'base64');\n\nmy $body = $msg->body;\nmy $decoded = $body->decoded;\nmy $encoded = $body->encode(transferencoding => '7bit');\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Manages the message's body encodings and decodings on request of the main program. This package\nadds functionality to the Mail::Message::Body class when the decoded() or encode() method is\ncalled.\n\nFour types of encodings are handled (in the right order)\n\n*   eol encoding\n\nVarious operating systems have different ideas about how to encode the line termination.\nUNIX uses a LF character, MacOS uses a CR, and Windows uses a CR/LF combination. Messages\nwhich are transported over Internet will always use the CRLF separator.\n\n*   transfer encoding\n\nMessages transmitted over Internet have to be plain ASCII. Complicated characters and binary\nfiles (like images and archives) must be encoded during transmission to an ASCII\nrepresentation.\n\nThe implementation of the required encoders and decoders is found in the\nMail::Message::TransferEnc set of packages. The related manual page lists the transfer\nencodings which are supported.\n\n*   mime-type translation\n\nNOT IMPLEMENTED YET\n\n*   charset conversion\n",
                "subsections": []
            },
            "METHODS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Constructing a body",
                        "content": "$obj->check()\nCheck the content of the body not to include illegal characters. Which characters are\nconsidered illegal depends on the encoding of this body.\n\nA body is returned which is checked. This may be the body where this method is called upon,\nbut also a new object, when serious changes had to be made. If the check could not be made,\nbecause the decoder is not defined, then \"undef\" is returned.\n\n$obj->encode(%options)\nEncode (translate) a Mail::Message::Body into a different format. See the DESCRIPTION above.\nOptions which are not specified will not trigger conversions.\n\n-Option           --Default\ncharset            PERL if text\nmimetype          undef\nresulttype        <same as source>\ntransferencoding  undef\n\ncharset => CODESET|'PERL'\nIf the CODESET is explicitly specified (for instance \"iso-8859-10\", then the data is\ninterpreted as raw bytes (blob), not as text. However, in case of \"PERL\", it is considered\nto be an internal representation of characters (either latin1 or Perl's utf8 --not the\nsame as utf-8--, you should not know).\n\nmimetype => STRING|FIELD\nConvert into the specified mime type, which can be specified as STRING or FIELD. The FIELD\nis a Mail::Message::Field, and the STRING is converted in such object before use.\n\nresulttype => CLASS\nThe type of body to be created when the body is changed to fulfill the request on\nre-coding. Also the intermediate stages in the translation process (if needed) will use\nthis type. CLASS must extend Mail::Message::Body.\n\ntransferencoding => STRING|FIELD\n\n$obj->encoded()\nEncode the body to a format what is acceptable to transmit or write to a folder file. This\nreturns the body where this method was called upon when everything was already prepared, or\na new encoded body otherwise. In either case, the body is checked.\n\n$obj->unify($body)\nUnify the type of the given $body objects with the type of the called body. \"undef\" is\nreturned when unification is impossible. If the bodies have the same settings, the $body\nobject is returned unchanged.\n\nExamples:\n\nmy $bodytype = Mail::Message::Body::Lines;\nmy $html  = $bodytype->new(mimetype=>'text/html', data => []);\nmy $plain = $bodytype->new(mimetype=>'text/plain', ...);\n\nmy $unified = $html->unify($plain);\n# $unified is the data of plain translated to html (if possible).\n"
                    },
                    {
                        "name": "About the payload",
                        "content": "$obj->dispositionFilename( [$directory] )\nVarious fields are searched for \"filename\" and \"name\" attributes. Without $directory, the\nname found will be returned unmodified.\n\nWhen a $directory is given, a filename is composed. For security reasons, only the basename\nof the found name gets used and many potentially dangerous characters removed. If no name\nwas found, or when the found name is already in use, then an unique name is generated.\n\nDon't forget to read RFC6266 section 4.3 for the security aspects in your email application.\n\n$obj->isBinary()\nReturns true when the un-encoded message is binary data. This information is retrieved from\nknowledge provided by MIME::Types.\n\n$obj->isText()\nReturns true when the un-encoded message contains printable text.\n"
                    },
                    {
                        "name": "Internals",
                        "content": "$obj->addTransferEncHandler( $name, <$class|$object> )\nMail::Message::Body->addTransferEncHandler( $name, <$class|$object> )\nRelate the NAMEd transfer encoding to an OBJECTs or object of the specified $class. In the\nlatter case, an object of that $class will be created on the moment that one is needed to do\nencoding or decoding.\n\nThe $class or $object must extend Mail::Message::TransferEnc. It will replace existing class\nand object for this $name.\n\nWhy aren't you contributing this class to MailBox?\n\n$obj->getTransferEncHandler($type)\nGet the transfer encoder/decoder which is able to handle $type, or return undef if there is\nno such handler.\n"
                    }
                ]
            },
            "DIAGNOSTICS": {
                "content": "Warning: Charset $name is not known\nThe encoding or decoding of a message body encounters a character set which is not\nunderstood by Perl's Encode module.\n\nWarning: No decoder defined for transfer encoding $name.\nThe data (message body) is encoded in a way which is not currently understood, therefore no\ndecoding (or recoding) can take place.\n\nWarning: No encoder defined for transfer encoding $name.\nThe data (message body) has been decoded, but the required encoding is unknown. The decoded\ndata is returned.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "This module is part of Mail-Message distribution version 3.012, built on February 11, 2022.\nWebsite: http://perl.overmeer.net/CPAN/\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://dev.perl.org/licenses/\n",
                "subsections": []
            }
        }
    }
}