{
    "content": [
        {
            "type": "text",
            "text": "# HTML::Entities (perldoc)\n\n## NAME\n\nHTML::Entities - Encode or decode strings with HTML entities\n\n## SYNOPSIS\n\nuse HTML::Entities;\n$a = \"V&aring;re norske tegn b&oslash;r &#230res\";\ndecodeentities($a);\nencodeentities($a, \"\\200-\\377\");\nFor example, this:\n$input = \"vis-à-vis Beyoncé's naïve\\npapier-mâché résumé\";\nprint encodeentities($input), \"\\n\"\nPrints this out:\nvis-&agrave;-vis Beyonc&eacute;'s na&iuml;ve\npapier-m&acirc;ch&eacute; r&eacute;sum&eacute;\n\n## DESCRIPTION\n\nThis module deals with encoding and decoding of strings with HTML character entities. The module\nprovides the following functions:\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (5 subsections)\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "HTML::Entities",
        "section": "",
        "mode": "perldoc",
        "summary": "HTML::Entities - Encode or decode strings with HTML entities",
        "synopsis": "use HTML::Entities;\n$a = \"V&aring;re norske tegn b&oslash;r &#230res\";\ndecodeentities($a);\nencodeentities($a, \"\\200-\\377\");\nFor example, this:\n$input = \"vis-à-vis Beyoncé's naïve\\npapier-mâché résumé\";\nprint encodeentities($input), \"\\n\"\nPrints this out:\nvis-&agrave;-vis Beyonc&eacute;'s na&iuml;ve\npapier-m&acirc;ch&eacute; r&eacute;sum&eacute;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": [
                    {
                        "name": "decode_entities",
                        "lines": 32
                    },
                    {
                        "name": "encode_entities",
                        "lines": 1
                    },
                    {
                        "name": "encode_entities",
                        "lines": 17
                    },
                    {
                        "name": "encode_entities_numeric",
                        "lines": 1
                    },
                    {
                        "name": "encode_entities_numeric",
                        "lines": 22
                    }
                ]
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "HTML::Entities - Encode or decode strings with HTML entities\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use HTML::Entities;\n\n$a = \"V&aring;re norske tegn b&oslash;r &#230res\";\ndecodeentities($a);\nencodeentities($a, \"\\200-\\377\");\n\nFor example, this:\n\n$input = \"vis-à-vis Beyoncé's naïve\\npapier-mâché résumé\";\nprint encodeentities($input), \"\\n\"\n\nPrints this out:\n\nvis-&agrave;-vis Beyonc&eacute;'s na&iuml;ve\npapier-m&acirc;ch&eacute; r&eacute;sum&eacute;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module deals with encoding and decoding of strings with HTML character entities. The module\nprovides the following functions:\n",
                "subsections": [
                    {
                        "name": "decode_entities",
                        "content": "This routine replaces HTML entities found in the $string with the corresponding Unicode\ncharacter. Unrecognized entities are left alone.\n\nIf multiple strings are provided as argument they are each decoded separately and the same\nnumber of strings are returned.\n\nIf called in void context the arguments are decoded in-place.\n\nThis routine is exported by default.\n\ndecodeentities( $string, \\%entity2char )\ndecodeentities( $string, \\%entity2char, $expandprefix )\nThis will in-place replace HTML entities in $string. The %entity2char hash must be provided.\nNamed entities not found in the %entity2char hash are left alone. Numeric entities are\nexpanded unless their value overflow.\n\nThe keys in %entity2char are the entity names to be expanded and their values are what they\nshould expand into. The values do not have to be single character strings. If a key has \";\"\nas suffix, then occurrences in $string are only expanded if properly terminated with \";\".\nEntities without \";\" will be expanded regardless of how they are terminated for\ncompatibility with how common browsers treat entities in the Latin-1 range.\n\nIf $expandprefix is TRUE then entities without trailing \";\" in %entity2char will even be\nexpanded as a prefix of a longer unrecognized name. The longest matching name in\n%entity2char will be used. This is mainly present for compatibility with an MSIE misfeature.\n\n$string = \"foo&nbspbar\";\ndecodeentities($string, { nb => \"@\", nbsp => \"\\xA0\" }, 1);\nprint $string;  # will print \"foo bar\"\n\nThis routine is exported by default.\n"
                    },
                    {
                        "name": "encode_entities",
                        "content": ""
                    },
                    {
                        "name": "encode_entities",
                        "content": "This routine replaces unsafe characters in $string with their entity representation. A\nsecond argument can be given to specify which characters to consider unsafe. The unsafe\ncharacters is specified using the regular expression character class syntax (what you find\nwithin brackets in regular expressions).\n\nThe default set of characters to encode are control chars, high-bit chars, and the \"<\", \"&\",\n\">\", \"'\" and \"\"\" characters. But this, for example, would encode *just* the \"<\", \"&\", \">\",\nand \"\"\" characters:\n\n$encoded = encodeentities($input, '<>&\"');\n\nand this would only encode non-plain ASCII:\n\n$encoded = encodeentities($input, '^\\n\\x20-\\x25\\x27-\\x7e');\n\nThis routine is exported by default.\n"
                    },
                    {
                        "name": "encode_entities_numeric",
                        "content": ""
                    },
                    {
                        "name": "encode_entities_numeric",
                        "content": "This routine works just like encodeentities, except that the replacement entities are\nalways \"&#x*hexnum*;\" and never \"&*entname*;\". For example, \"encodeentities(\"r\\xF4le\")\"\nreturns \"r&ocirc;le\", but \"encodeentitiesnumeric(\"r\\xF4le\")\" returns \"r&#xF4;le\".\n\nThis routine is *not* exported by default. But you can always export it with \"use\nHTML::Entities qw(encodeentitiesnumeric);\" or even \"use HTML::Entities qw(:DEFAULT\nencodeentitiesnumeric);\"\n\nAll these routines modify the string passed as the first argument, if called in a void context.\nIn scalar and array contexts, the encoded or decoded string is returned (without changing the\ninput string).\n\nIf you prefer not to import these routines into your namespace, you can call them as:\n\nuse HTML::Entities ();\n$decoded = HTML::Entities::decode($a);\n$encoded = HTML::Entities::encode($a);\n$encoded = HTML::Entities::encodenumeric($a);\n\nThe module can also export the %char2entity and the %entity2char hashes, which contain the\nmapping from all characters to the corresponding entities (and vice versa, respectively).\n"
                    }
                ]
            },
            "COPYRIGHT": {
                "content": "Copyright 1995-2006 Gisle Aas. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}