SOURCE::ENCODING(3perl)
β¨ NAME β¨
source::encoding β bestie it literally just declares your Perl source code encoding π
It's a 3perl page, so it's living in the Perl Programmers Reference Guide corner of the world π
πΈ SYNOPSIS πΈ
use source::encoding 'ascii';
use source::encoding 'utf8';
no source::encoding;
π DESCRIPTION π
okay so here's the tea β β these days, Perl code kinda falls into one of two lanes:
- it contains only ASCII characters, and you use
"\x{}"and similar escapes to represent anything non-ASCII, or - you slap a
use utf8in there to say "hey bestie, the source code itself contains characters encoded as UTF-8" π
so a character in the source code that fits neither of those criteria? that's usually just a typo π like someone fat-fingered a smart quote or a fancy dash in there. This pragma exists so you can tell Perl: "raise an error when this happens, king" π₯
use source::encoding 'utf8' is a synonym for use utf8. They may be used interchangeably β same energy, no cap π«Ά
use source::encoding 'ascii' turns off any UTF-8 expectations, and raises a fatal error if any character within its scope in the input source code is not ASCII (or ASCII-equivalent on EBCDIC systems). like it's not mad, it's just disappointed π
no source::encoding turns off any UTF-8/ASCII expectations for the remainder of its scope. The meaning of non-ASCII characters is then undefined π so like, proceed with caution bestie.
oh and also βuse source::encoding 'ascii'is automatically enabled within the lexical scope of ause v5.41.0or higher π so you might get this vibe for free and not even know it.
π¦ SEE ALSO π¦
utf8
and that's the whole page, fr fr β¨ this absolute icon is documented as perl v5.44.0, dated 2026-10-17, and it goes by source::encoding(3perl). love that for us π π π§
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms