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 toGB2312(raw). π¦iso-ir-165βGB2312+GB6345+GB8565+ additions. it's giving collab.MacChineseSimpβGB2312+ Apple Additions. πcp936β Code Page 936, also known asGBK(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