{
    "content": [
        {
            "type": "text",
            "text": "# Encode::Alias (perldoc)\n\n**Summary:** Encode::Alias - alias definitions to encodings\n\n**Synopsis:** use Encode;\nuse Encode::Alias;\ndefinealias( \"newName\" => ENCODING);\ndefinealias( qr/.../ => ENCODING);\ndefinealias( sub { return ENCODING if ...; } );\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (6 lines)\n- **DESCRIPTION** (44 lines) — 1 subsections\n  - Alias overloading (23 lines)\n- **SEE ALSO** (2 lines)\n\n## Full Content\n\n### NAME\n\nEncode::Alias - alias definitions to encodings\n\n### SYNOPSIS\n\nuse Encode;\nuse Encode::Alias;\ndefinealias( \"newName\" => ENCODING);\ndefinealias( qr/.../ => ENCODING);\ndefinealias( sub { return ENCODING if ...; } );\n\n### DESCRIPTION\n\nAllows newName to be used as an alias for ENCODING. ENCODING may be either the name of an\nencoding or an encoding object (as described in Encode).\n\nCurrently the first argument to definealias() can be specified in the following ways:\n\nAs a simple string.\nAs a qr// compiled regular expression, e.g.:\ndefinealias( qr/^iso8859-(\\d+)$/i => '\"iso-8859-$1\"' );\n\nIn this case, if *ENCODING* is not a reference, it is \"eval\"-ed in order to allow $1 etc. to\nbe substituted. The example is one way to alias names as used in X11 fonts to the MIME names\nfor the iso-8859-* family. Note the double quotes inside the single quotes.\n\n(or, you don't have to do this yourself because this example is predefined)\n\nIf you are using a regex here, you have to use the quotes as shown or it won't work. Also\nnote that regex handling is tricky even for the experienced. Use this feature with caution.\n\nAs a code reference, e.g.:\ndefinealias( sub {shift =~ /^iso8859-(\\d+)$/i ? \"iso-8859-$1\" : undef } );\n\nThe same effect as the example above in a different way. The coderef takes the alias name as\nan argument and returns a canonical name on success or undef if not. Note the second\nargument is ignored if provided. Use this with even more caution than the regex version.\n\nChanges in code reference aliasing\nAs of Encode 1.87, the older form\n\ndefinealias( sub { return  /^iso8859-(\\d+)$/i ? \"iso-8859-$1\" : undef } );\n\nno longer works.\n\nEncode up to 1.86 internally used \"local $\" to implement this older form. But consider the code\nbelow;\n\nuse Encode;\n$ = \"eeeee\" ;\nwhile (/(e)/g) {\nmy $utf = decode('aliased-encoding-name', $1);\nprint \"position:\",pos,\"\\n\";\n}\n\nPrior to Encode 1.86 this fails because of \"local $\".\n\n#### Alias overloading\n\nYou can override predefined aliases by simply applying definealias(). The new alias is always\nevaluated first, and when necessary, definealias() flushes the internal cache to make the new\ndefinition available.\n\n# redirect SHIFTJIS to MS/IBM Code Page 932, which is a\n# superset of SHIFTJIS\n\ndefinealias( qr/shift.*jis$/i  => '\"cp932\"' );\ndefinealias( qr/sjis$/i        => '\"cp932\"' );\n\nIf you want to zap all predefined aliases, you can use\n\nEncode::Alias->undefaliases;\n\nto do so. And\n\nEncode::Alias->initaliases;\n\ngets the factory settings back.\n\nNote that definealias() will not be able to override the canonical name of encodings. Encodings\nare first looked up by canonical name before potential aliases are tried.\n\n### SEE ALSO\n\nEncode, Encode::Supported\n\n"
        }
    ],
    "structuredContent": {
        "command": "Encode::Alias",
        "section": "",
        "mode": "perldoc",
        "summary": "Encode::Alias - alias definitions to encodings",
        "synopsis": "use Encode;\nuse Encode::Alias;\ndefinealias( \"newName\" => ENCODING);\ndefinealias( qr/.../ => ENCODING);\ndefinealias( sub { return ENCODING if ...; } );",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 44,
                "subsections": [
                    {
                        "name": "Alias overloading",
                        "lines": 23
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Encode::Alias - alias definitions to encodings\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Encode;\nuse Encode::Alias;\ndefinealias( \"newName\" => ENCODING);\ndefinealias( qr/.../ => ENCODING);\ndefinealias( sub { return ENCODING if ...; } );\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Allows newName to be used as an alias for ENCODING. ENCODING may be either the name of an\nencoding or an encoding object (as described in Encode).\n\nCurrently the first argument to definealias() can be specified in the following ways:\n\nAs a simple string.\nAs a qr// compiled regular expression, e.g.:\ndefinealias( qr/^iso8859-(\\d+)$/i => '\"iso-8859-$1\"' );\n\nIn this case, if *ENCODING* is not a reference, it is \"eval\"-ed in order to allow $1 etc. to\nbe substituted. The example is one way to alias names as used in X11 fonts to the MIME names\nfor the iso-8859-* family. Note the double quotes inside the single quotes.\n\n(or, you don't have to do this yourself because this example is predefined)\n\nIf you are using a regex here, you have to use the quotes as shown or it won't work. Also\nnote that regex handling is tricky even for the experienced. Use this feature with caution.\n\nAs a code reference, e.g.:\ndefinealias( sub {shift =~ /^iso8859-(\\d+)$/i ? \"iso-8859-$1\" : undef } );\n\nThe same effect as the example above in a different way. The coderef takes the alias name as\nan argument and returns a canonical name on success or undef if not. Note the second\nargument is ignored if provided. Use this with even more caution than the regex version.\n\nChanges in code reference aliasing\nAs of Encode 1.87, the older form\n\ndefinealias( sub { return  /^iso8859-(\\d+)$/i ? \"iso-8859-$1\" : undef } );\n\nno longer works.\n\nEncode up to 1.86 internally used \"local $\" to implement this older form. But consider the code\nbelow;\n\nuse Encode;\n$ = \"eeeee\" ;\nwhile (/(e)/g) {\nmy $utf = decode('aliased-encoding-name', $1);\nprint \"position:\",pos,\"\\n\";\n}\n\nPrior to Encode 1.86 this fails because of \"local $\".\n",
                "subsections": [
                    {
                        "name": "Alias overloading",
                        "content": "You can override predefined aliases by simply applying definealias(). The new alias is always\nevaluated first, and when necessary, definealias() flushes the internal cache to make the new\ndefinition available.\n\n# redirect SHIFTJIS to MS/IBM Code Page 932, which is a\n# superset of SHIFTJIS\n\ndefinealias( qr/shift.*jis$/i  => '\"cp932\"' );\ndefinealias( qr/sjis$/i        => '\"cp932\"' );\n\nIf you want to zap all predefined aliases, you can use\n\nEncode::Alias->undefaliases;\n\nto do so. And\n\nEncode::Alias->initaliases;\n\ngets the factory settings back.\n\nNote that definealias() will not be able to override the canonical name of encodings. Encodings\nare first looked up by canonical name before potential aliases are tried.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "Encode, Encode::Supported\n",
                "subsections": []
            }
        }
    }
}