Encode::CN(3perl)

πŸ’– Encode::CN β€” China-based Chinese Encodings πŸ’–

okay so bestie, this is Encode::CN, straight out of the Perl Programmers Reference Guide. It's the little module that handles Chinese charsets from China, and honestly? she's a lot. let's get into it πŸŽ€


✨ SYNOPSIS ✨

use Encode qw/encode decode/;
$euc_cn = encode("euc-cn", $utf8);   # loads Encode::CN implicitly
$utf8   = decode("euc-cn", $euc_cn); # ditto

no cap, the module just kinda shows up on its own when you ask for the encoding β€” it loads itself implicitly. main character energy fr πŸ’…


🌸 DESCRIPTION 🌸

so this module implements the China-based Chinese charset encodings. here's the whole roster, canonical name first, then the aliases, then the vibe:

  • euc-cn β€” aliases: /\beuc.*cn$/i, /\bcn.*euc$/i, /\bGB[-_ ]?2312(?:\D.*$|$)/i (see below). Description: EUC (Extended Unix Character).
  • gb2312-raw β€” the raw (low-bit) GB2312 character map. yes, raw. lowercase bits and all.
  • gb12345-raw β€” the Traditional chinese counterpart to GB2312 (raw). πŸ¦‹
  • iso-ir-165 β€” GB2312 + GB6345 + GB8565 + additions. it's giving collab.
  • MacChineseSimp β€” GB2312 + Apple Additions. 🍎
  • cp936 β€” Code Page 936, also known as GBK (Extended GuoBiao).
  • hz β€” 7-bit escaped GB2312 encoding.

and if you wanna know how to actually use this module in detail, go see Encode. she's the parent, she has the lore. πŸ’œ


πŸ‘‘ NOTES πŸ‘‘

okay important tea: due to size concerns, GB 18030 (which is an extension to GBK) is distributed separately on CPAN, under the name Encode::HanExtra. and that module also contains extra Taiwan-based encodings, so if you're looking for those, that's where they went. she moved out. 🧳✨


πŸ’€ BUGS πŸ’€

so when you see charset=gb2312 on mails and web pages?? they really mean euc-cn encodings. iconic of them to lie. 😭 to fix that, gb2312 is aliased to euc-cn. so use gb2312-raw when you really mean it β€” don't get played, bestie.

also: the ASCII region (0x00-0x7f) is preserved for all encodings, even though this conflicts with mappings by the Unicode Consortium. so like, yes, it's a whole thing, and no, we're not changing it. 🫠


πŸ”₯ SEE ALSO πŸ”₯

  • Encode

that's the whole page, bestie, you ate it πŸ’…βœ¨ β€” this was Encode::CN(3perl) from the Perl Programmers Reference Guide, landing with perl v5.44.0 on 2026-10-17. periodt. πŸŽ€πŸ¦‹β­

πŸ“¦ 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