{
    "content": [
        {
            "type": "text",
            "text": "# Encode::Encoder (perldoc)\n\n## NAME\n\nEncode::Encoder -- Object Oriented Encoder\n\n## SYNOPSIS\n\nuse Encode::Encoder;\n# Encode::encode(\"ISO-8859-1\", $data);\nEncode::Encoder->new($data)->iso88591; # OOP way\n# shortcut\nuse Encode::Encoder qw(encoder);\nencoder($data)->iso88591;\n# you can stack them!\nencoder($data)->iso88591->base64;  # provided base64() is defined\n# you can use it as a decoder as well\nencoder($base64)->bytes('base64')->latin1;\n# stringified\nprint encoder($data)->utf8->latin1;  # prints the string in latin1\n# numified\nencoder(\"\\x{abcd}\\x{ef}g\")->utf8 == 6; # true. bytes::length($data)\n\n## DESCRIPTION\n\nHere is how to use this module.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **ABSTRACT**\n- **Description** (4 subsections)\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Encode::Encoder",
        "section": "",
        "mode": "perldoc",
        "summary": "Encode::Encoder -- Object Oriented Encoder",
        "synopsis": "use Encode::Encoder;\n# Encode::encode(\"ISO-8859-1\", $data);\nEncode::Encoder->new($data)->iso88591; # OOP way\n# shortcut\nuse Encode::Encoder qw(encoder);\nencoder($data)->iso88591;\n# you can stack them!\nencoder($data)->iso88591->base64;  # provided base64() is defined\n# you can use it as a decoder as well\nencoder($base64)->bytes('base64')->latin1;\n# stringified\nprint encoder($data)->utf8->latin1;  # prints the string in latin1\n# numified\nencoder(\"\\x{abcd}\\x{ef}g\")->utf8 == 6; # true. bytes::length($data)",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "ABSTRACT",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "Description",
                "lines": 11,
                "subsections": [
                    {
                        "name": "Predefined Methods",
                        "lines": 9
                    },
                    {
                        "name": "encoder",
                        "lines": 17
                    },
                    {
                        "name": "Example: base64 transcoder",
                        "lines": 28
                    },
                    {
                        "name": "Operator Overloading",
                        "lines": 8
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Encode::Encoder -- Object Oriented Encoder\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Encode::Encoder;\n# Encode::encode(\"ISO-8859-1\", $data);\nEncode::Encoder->new($data)->iso88591; # OOP way\n# shortcut\nuse Encode::Encoder qw(encoder);\nencoder($data)->iso88591;\n# you can stack them!\nencoder($data)->iso88591->base64;  # provided base64() is defined\n# you can use it as a decoder as well\nencoder($base64)->bytes('base64')->latin1;\n# stringified\nprint encoder($data)->utf8->latin1;  # prints the string in latin1\n# numified\nencoder(\"\\x{abcd}\\x{ef}g\")->utf8 == 6; # true. bytes::length($data)\n",
                "subsections": []
            },
            "ABSTRACT": {
                "content": "Encode::Encoder allows you to use Encode in an object-oriented style. This is not only more\nintuitive than a functional approach, but also handier when you want to stack encodings. Suppose\nyou want your UTF-8 string converted to Latin1 then Base64: you can simply say\n\nmy $base64 = encoder($utf8)->latin1->base64;\n\ninstead of\n\nmy $latin1 = encode(\"latin1\", $utf8);\nmy $base64 = encodebase64($utf8);\n\nor the lazier and more convoluted\n\nmy $base64 = encodebase64(encode(\"latin1\", $utf8));\n",
                "subsections": []
            },
            "Description": {
                "content": "Here is how to use this module.\n\n*   There are at least two instance variables stored in a hash reference, {data} and {encoding}.\n\n*   When there is no method, it takes the method name as the name of the encoding and encodes\nthe instance *data* with *encoding*. If successful, the instance *encoding* is set\naccordingly.\n\n*   You can retrieve the result via ->data but usually you don't have to because the stringify\noperator (\"\") is overridden to do exactly that.\n",
                "subsections": [
                    {
                        "name": "Predefined Methods",
                        "content": "This module predefines the methods below:\n\n$e = Encode::Encoder->new([$data, $encoding]);\nreturns an encoder object. Its data is initialized with $data if present, and its encoding\nis set to $encoding if present.\n\nWhen $encoding is omitted, it defaults to utf8 if $data is already in utf8 or \"\" (empty\nstring) otherwise.\n"
                    },
                    {
                        "name": "encoder",
                        "content": "is an alias of Encode::Encoder->new(). This one is exported on demand.\n\n$e->data([$data])\nWhen $data is present, sets the instance data to $data and returns the object itself.\nOtherwise, the current instance data is returned.\n\n$e->encoding([$encoding])\nWhen $encoding is present, sets the instance encoding to $encoding and returns the object\nitself. Otherwise, the current instance encoding is returned.\n\n$e->bytes([$encoding])\ndecodes instance data from $encoding, or the instance encoding if omitted. If the conversion\nis successful, the instance encoding will be set to \"\".\n\nThe name *bytes* was deliberately picked to avoid namespace tainting -- this module may be\nused as a base class so method names that appear in Encode::Encoding are avoided.\n"
                    },
                    {
                        "name": "Example: base64 transcoder",
                        "content": "This module is designed to work with Encode::Encoding. To make the Base64 transcoder example\nabove really work, you could write a module like this:\n\npackage Encode::Base64;\nuse parent 'Encode::Encoding';\nPACKAGE->Define('base64');\nuse MIME::Base64;\nsub encode{\nmy ($obj, $data) = @;\nreturn encodebase64($data);\n}\nsub decode{\nmy ($obj, $data) = @;\nreturn decodebase64($data);\n}\n1;\nEND\n\nAnd your caller module would be something like this:\n\nuse Encode::Encoder;\nuse Encode::Base64;\n\n# now you can really do the following\n\nencoder($data)->iso88591->base64;\nencoder($base64)->bytes('base64')->latin1;\n"
                    },
                    {
                        "name": "Operator Overloading",
                        "content": "This module overloads two operators, stringify (\"\") and numify (0+).\n\nStringify dumps the data inside the object.\n\nNumify returns the number of bytes in the instance data.\n\nThey come in handy when you want to print or find the size of data.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "Encode, Encode::Encoding\n",
                "subsections": []
            }
        }
    }
}