You are viewing the version of this documentation from Perl 5.22.4. View the latest version
${^ENCODING}

DEPRECATED!!!

The object reference to the Encode object that is used to convert the source code to Unicode. Thanks to this variable your Perl script does not have to be written in UTF-8. Default is undef.

Setting this variable to any other value than undef is deprecated due to fundamental defects in its design and implementation. It is planned to remove it from a future Perl version. Its purpose was to allow your non-ASCII Perl scripts to not have to be written in UTF-8; this was useful before editors that worked on UTF-8 encoded text were common, but that was long ago. It causes problems, such as affecting the operation of other modules that aren't expecting it, causing general mayhem. Its use can lead to segfaults.

If you need something like this functionality, you should use the encoding pragma, which is also deprecated, but has fewer nasty side effects.

If you are coming here because code of yours is being adversely affected by someone's use of this variable, you can usually work around it by doing this:

local ${^ENCODING};

near the beginning of the functions that are getting broken. This undefines the variable during the scope of execution of the including function.

This variable was added in Perl 5.8.2.