Encode::CN — China-based Chinese Encodings
| Use Case | Command | Description |
|---|---|---|
| 🔤 Encode UTF-8 to EUC-CN | encode("euc-cn", $utf8) | Convert UTF-8 string to Chinese EUC (Extended Unix Character) encoding |
| 🔤 Decode EUC-CN to UTF-8 | decode("euc-cn", $euc_cn) | Convert Chinese EUC encoded string back to UTF-8 |
| 📦 Load Encode::CN module | use Encode qw/encode decode/; | Load Encode module with encode/decode functions; Encode::CN loads automatically when needed |
| 🇨🇳 Use GBK (cp936) encoding | encode("cp936", $utf8) | Encode using Code Page 936 (GBK, Extended GuoBiao) |
| 🇨🇳 Use HZ encoding | encode("hz", $utf8) | Encode using 7-bit escaped GB2312 encoding |
| 🇨🇳 Use raw GB2312 | encode("gb2312-raw", $utf8) | Encode using raw (low-bit) GB2312 character map |
| 📘 Extended Chinese encodings | use Encode::HanExtra; | Load additional encodings (GB 18030, Taiwan-based) from CPAN |
use Encode qw/encode decode/;
$euc_cn = encode("euc-cn", $utf8); # loads Encode::CN implicitly
$utf8 = decode("euc-cn", $euc_cn); # ditto
This module implements China-based Chinese charset encodings. Encodings supported are as follows.
| Canonical | Alias | Description |
|---|---|---|
| euc-cn | /\beuc.*cn$/i/\bcn.*euc$/i/\bGB[-_ ]?2312(?:\D.*$|$)/i | EUC (Extended Unix Character) |
| gb2312-raw | 🟤 The raw (low-bit) GB2312 character map | |
| gb12345-raw | 🟤 Traditional Chinese counterpart to GB2312 (raw) | |
| iso-ir-165 | 📚 GB2312 + GB6345 + GB8565 + additions | |
| MacChineseSimp | 🍏 GB2312 + Apple Additions | |
| cp936 | 📄 Code Page 936, also known as GBK (Extended GuoBiao) | |
| hz | 🔤 7-bit escaped GB2312 encoding |
To find how to use this module in detail, see Encode.
Due to size concerns, "GB 18030" (an extension to "GBK") is distributed separately on CPAN, under the name Encode::HanExtra. That module also contains extra Taiwan-based encodings.
charset=gb2312 on mails and web pages, they really mean euc-cn encodings. To fix that, gb2312 is aliased to euc-cn. Use gb2312-raw when you really mean it.Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-11 04:27 @216.73.216.11
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)