SOURCE::ENCODING(3perl)

πŸ“¦
version 5.44.0 Β· 3 versions
, in arch rolling

✨ 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 utf8 in 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 a use v5.41.0 or 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