Encode::Supported -- Encodings supported by Encode
Encoding names are case insensitive. White space in names is ignored. In addition, an encoding may have aliases. Each encoding has one "canonical" name. The "canonical" name is chosen from the names of the encoding by picking the first in the following sequence (with a few exceptions).
The name used by the Perl community. That includes 'utf8' and 'ascii'. Unlike aliases, canonical names directly reach the method so such frequently used words like 'utf8' don't need to do alias lookups.
The MIME name as defined in IETF RFCs. This includes all "iso-"s.
The name in the IANA registry.
The name used by the organization that defined it.
In casede jure canonical names differ from that of the Encode module, they are always aliased if it ever be implemented. So you can safely tell if a given encoding is implemented or not just by passing the canonical name.
Because of all the alias issues, and because in the general case encodings have state, "Encode" uses an encoding object internally once an operation is in progress.
As of Perl 5.8.0, at least the following encodings are recognized. Note that unless otherwise specified, they are all case insensitive (via alias) and all occurrence of spaces are replaced with '-'. In other words, "ISO 8859 1" and "iso-8859-1" are identical.
Encodings are categorized and implemented in several different modules but you don't have touse Encode::XX
to make them available for most cases. Encode.pm will automatically load those modules on demand.
The following encodings are always available.
Canonical Aliases Comments & References----------------------------------------------------------------ascii US-ascii ISO-646-US [ECMA]ascii-ctrl Special Encodingiso-8859-1 latin1 [ISO]null Special Encodingutf8 UTF-8 [RFC2279]----------------------------------------------------------------
null andascii-ctrl are special. "null" fails for all character so when you set fallback mode to PERLQQ, HTMLCREF or XMLCREF, ALL CHARACTERS will fall back to character references. Ditto for "ascii-ctrl" except for control characters. For fallback modes, seeEncode.
Unicode coding schemes other than native utf8 are supported by Encode::Unicode, which will be autoloaded on demand.
----------------------------------------------------------------UCS-2BE UCS-2, iso-10646-1 [IANA, UC]UCS-2LE [UC]UTF-16 [UC]UTF-16BE [UC]UTF-16LE [UC]UTF-32 [UC]UTF-32BEUCS-4 [UC]UTF-32LE [UC]UTF-7 [RFC2152]----------------------------------------------------------------
To find how (UCS-2|UTF-(16|32))(LE|BE)? differ from one another, seeEncode::Unicode.
UTF-7 is a special encoding which "re-encodes" UTF-16BE into a 7-bit encoding. It is implemented separately by Encode::Unicode::UTF7.
Encode::Byte implements most single-byte encodings except for Symbols and EBCDIC. The following encodings are based on single-byte encodings implemented as extended ASCII. Most of them map \x80-\xff (upper half) to non-ASCII characters.
Since there are so many, they are presented in table format with languages and corresponding encoding names by vendors. Note that the table is sorted in order of ISO-8859 and the corresponding vendor mappings are slightly different from that of ISO. Seehttp://czyborra.com/charsets/iso8859.html for details.
Lang/Regions ISO/Other Std. DOS Windows Macintosh Others----------------------------------------------------------------N. America (ASCII) cp437 AdobeStandardEncoding cp863 (DOSCanadaF)W. Europe iso-8859-1 cp850 cp1252 MacRoman nextstep hp-roman8 cp860 (DOSPortuguese)Cntrl. Europe iso-8859-2 cp852 cp1250 MacCentralEurRoman MacCroatian MacRomanian MacRumanianLatin3[1] iso-8859-3 Latin4[2] iso-8859-4 Cyrillics iso-8859-5 cp855 cp1251 MacCyrillic (See also next section) cp866 MacUkrainianArabic iso-8859-6 cp864 cp1256 MacArabic cp1006 MacFarsiGreek iso-8859-7 cp737 cp1253 MacGreek cp869 (DOSGreek2)Hebrew iso-8859-8 cp862 cp1255 MacHebrewTurkish iso-8859-9 cp857 cp1254 MacTurkishNordics iso-8859-10 cp865 cp861 MacIcelandic MacSamiThai iso-8859-11[3] cp874 MacThai(iso-8859-12 is nonexistent. Reserved for Indics?)Baltics iso-8859-13 cp775 cp1257Celtics iso-8859-14Latin9 [4] iso-8859-15Latin10 iso-8859-16Vietnamese viscii cp1258 MacVietnamese----------------------------------------------------------------[1] Esperanto, Maltese, and Turkish. Turkish is now on 8859-9.[2] Baltics. Now on 8859-10, except for Latvian.[3] TIS 620 + Non-Breaking Space (0xA0 / U+00A0)[4] Nicknamed Latin0; the Euro sign as well as French and Finnish letters that are missing from 8859-1 were added.
All cp* are also available as ibm-*, ms-*, and windows-* . See alsohttp://czyborra.com/charsets/codepages.html.
Macintosh encodings don't seem to be registered in such entities as IANA. "Canonical" names in Encode are based upon Apple's Tech Note 1150. Seehttp://developer.apple.com/technotes/tn/tn1150.html for details.
Though ISO-8859 does have ISO-8859-5, the KOI8 series is far more popular in the Net.Encode comes with the following KOI charsets. For gory details, seehttp://czyborra.com/charsets/cyrillic.html
----------------------------------------------------------------koi8-f koi8-r cp878 [RFC1489]koi8-u [RFC2319]----------------------------------------------------------------
GSM0338 is for GSM handsets. Though it shares alphanumerals with ASCII, control character ranges and other parts are mapped very differently, mainly to store Greek characters. There are also escape sequences (starting with 0x1B) to cover e.g. the Euro sign.
This was once handled byEncode::Bytes but because of all those unusual specifications, Encode 2.20 has relocated the support toEncode::GSM0338. SeeEncode::GSM0338 for details.
Some special cases like a trailing 0x00 byte or a lone 0x1B byte are not well-defined and decode() will return an empty string for them. One possible workaround is
$gsm =~ s/\x00\z/\x00\x00/;$uni = decode("gsm0338", $gsm);$uni .= "\xA0" if $gsm =~ /\x1B\z/;
Note that the Encode implementation of GSM0338 does not implement the reuse of Latin capital letters as Greek capital letters (for example, the 0x5A is U+005A (LATIN CAPITAL LETTER Z), not U+0396 (GREEK CAPITAL LETTER ZETA).
The GSM0338 is also covered in Encode::Byte even though it is not an "extended ASCII" encoding.
Note that Vietnamese is listed above. Also read "Encoding vs Charset" below. Also note that these are implemented in distinct modules by countries, due to the size concerns (simplified Chinese is mapped to 'CN', continental China, while traditional Chinese is mapped to 'TW', Taiwan). Please refer to their respective documentation pages.
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------euc-cn [1] MacChineseSimp(gbk) cp936 [2]gb12345-raw { GB12345 without CES }gb2312-raw { GB2312 without CES }hziso-ir-165----------------------------------------------------------------[1] GB2312 is aliased to this. See L<Microsoft-related naming mess>[2] gbk is aliased to this. See L<Microsoft-related naming mess>
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------euc-jpshiftjis cp932 macJapanese7bit-jisiso-2022-jp [RFC1468]iso-2022-jp-1 [RFC2237]jis0201-raw { JIS X 0201 (roman + halfwidth kana) without CES }jis0208-raw { JIS X 0208 (Kanji + fullwidth kana) without CES }jis0212-raw { JIS X 0212 (Extended Kanji) without CES }----------------------------------------------------------------
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------euc-kr MacKorean [RFC1557] cp949 [1] iso-2022-kr [RFC1557]johab [KS X 1001:1998, Annex 3]ksc5601-raw { KSC5601 without CES }----------------------------------------------------------------[1] ks_c_5601-1987, (x-)?windows-949, and uhc are aliased to this.See below.
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------big5-eten cp950 MacChineseTrad {big5 aliased to big5-eten}big5-hkscs ----------------------------------------------------------------
Due to the size concerns, additional Chinese encodings below are distributed separately on CPAN, under the name Encode::HanExtra.
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------big5ext CMEX's Big5e Extensionbig5plus CMEX's Big5+ Extensioncccii Chinese Character Code for Information Interchangeeuc-tw EUC (Extended Unix Character)gb18030 GBK with Traditional Characters----------------------------------------------------------------
Due to size concerns, additional Japanese encodings below are distributed separately on CPAN, under the name Encode::JIS2K.
Standard DOS/Win Macintosh Comment/Reference----------------------------------------------------------------euc-jisx0213shiftjisx0123iso-2022-jp-3jis0213-1-rawjis0213-2-raw----------------------------------------------------------------
Seeperlebcdic for details.
----------------------------------------------------------------cp37cp500 cp875 cp1026 cp1047 posix-bc----------------------------------------------------------------
For symbols and dingbats.
----------------------------------------------------------------symboldingbatsMacDingbatsAdobeZdingbatAdobeSymbol----------------------------------------------------------------
Strictly speaking, MIME header encoding documented in RFC 2047 is more of encapsulation than encoding. However, their support in modern world is imperative so they are supported.
----------------------------------------------------------------MIME-Header [RFC2047]MIME-B [RFC2047]MIME-Q [RFC2047]----------------------------------------------------------------
This one is not a name of encoding but a utility that lets you pick up the most appropriate encoding for a data out of givensuspects. SeeEncode::Guess for details.
The following encodings are not supported as yet; some because they are rarely used, some because of technical difficulties. They may be supported by external modules via CPAN in the future, however.
Not very popular yet. Needs Unicode Database or equivalent to implement encode() (because it includes JIS X 0208/0212, KSC5601, and GB2312 simultaneously, whose code points in Unicode overlap. So you need to lookup the database to determine to what character set a given Unicode character should belong).
Not very popular. Needs CNS 11643-1 and -2 which are not available in this module. CNS 11643 is supported (via euc-tw) in Encode::HanExtra. Audrey Tang may add support for this encoding in her module in future.
The following are unsupported due to the lack of mapping data.
'8' - arabic8, greek8, hebrew8, kana8, thai8, and turkish8'15' - japanese15, korean15, and roi15
Anton Tagunov doubts its usefulness.
None of the Encode team knows Hebrew enough (ISO-8859-8, cp1255 and MacHebrew are supported because and just because there were mappings available athttp://www.unicode.org/). Contributions welcome.
Ditto.
Ditto.
Though Jungshik Shin has reported that Mozilla supports this encoding, it was too late before 5.8.0 for us to add it. In the future, it may be available via a separate module. Seehttp://lxr.mozilla.org/seamonkey/source/intl/uconv/ucvlatin/vps.uf andhttp://lxr.mozilla.org/seamonkey/source/intl/uconv/ucvlatin/vps.ut if you are interested in helping us.
The following are unsupported due to the lack of mapping data.
MacArmenian, MacBengali, MacBurmese, MacEthiopicMacExtArabic, MacGeorgian, MacKannada, MacKhmerMacLaotian, MacMalayalam, MacMongolian, MacOriyaMacSinhalese, MacTamil, MacTelugu, MacTibetanMacVietnamese
The rest which are already available are based upon the vendor mappings athttp://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ .
The maps for the following are available athttp://www.unicode.org/ but remain unsupported because those encodings need an algorithmical approach, currently unsupported byenc2xs:
MacDevanagariMacGurmukhiMacGujarati
For details, please seeUnicode mapping issues and notes:
athttp://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/DEVANAGA.TXT .
I believe this issue is prevalent not only for Mac Indics but also in other Indic encodings, but the above were the only Indic encodings maps that I could find athttp://www.unicode.org/ .
We are used to using the term (character)encoding andcharacter set interchangeably. But just as confusing the terms byte and character is dangerous and the terms should be differentiated when needed, we need to differentiateencoding andcharacter set.
To understand that, here is a description of how we make computers grok our characters.
First we start with which characters to include. We call this collection of characterscharacter repertoire.
Then we have to give each character a unique ID so your computer can tell the difference between 'a' and 'A'. This itemized character repertoire is now acharacter set.
If your computer can grow the character set without further processing, you can go ahead and use it. This is called acoded character set (CCS) orraw character encoding. ASCII is used this way for most cases.
But in many cases, especially multi-byte CJK encodings, you have to tweak a little more. Your network connection may not accept any data with the Most Significant Bit set, and your computer may not be able to tell if a given byte is a whole character or just half of it. So you have toencode the character set to use it.
Acharacter encoding scheme (CES) determines how to encode a given character set, or a set of multiple character sets. 7bit ISO-2022 is an example of a CES. You switch between character sets viaescape sequences.
Technically, or mathematically, speaking, a character set encoded in such a CES that maps character by character may form a CCS. EUC is such an example. The CES of EUC is as follows:
Map ASCII unchanged.
Map such a character set that consists of 94 or 96 powered by N members by adding 0x80 to each byte.
You can also use 0x8e and 0x8f to indicate that the following sequence of characters belongs to yet another character set. To each following byte is added the value 0x80.
By carefully looking at the encoded byte sequence, you can find that the byte sequence conforms a unique number. In that sense, EUC is a CCS generated by a CES above from up to four CCS (complicated?). UTF-8 falls into this category. See"UTF-8" in perlUnicode to find out how UTF-8 maps Unicode to a byte sequence.
You may also have found out by now why 7bit ISO-2022 cannot comprise a CCS. If you look at a byte sequence \x21\x21, you can't tell if it is two !'s or IDEOGRAPHIC SPACE. EUC maps the latter to \xA1\xA1 so you have no trouble differentiating between "!!". and" ".
This section tries to classify the supported encodings by their applicability for information exchange over the Internet and to choose the most suitable aliases to name them in the context of such communication.
To (en|de)code encodings marked by(**)
, you needEncode::HanExtra
, available from CPAN.
Encoding names
US-ASCII UTF-8 ISO-8859-* KOI8-RShift_JIS EUC-JP ISO-2022-JP ISO-2022-JP-1EUC-KR Big5 GB2312
are registered with IANA as preferred MIME names and may be used over the Internet.
Shift_JIS
has been officialized by JIS X 0208:1997."Microsoft-related naming mess" gives details.
GB2312
is the IANA name forEUC-CN
. See"Microsoft-related naming mess" for details.
GB_2312-80
raw encoding is available asgb2312-raw
with Encode. SeeEncode::CN for details.
EUC-CNKOI8-U [RFC2319]
have not been registered with IANA (as of March 2002) but seem to be supported by major web browsers. The IANA name forEUC-CN
isGB2312
.
KS_C_5601-1987
is heavily misused. See"Microsoft-related naming mess" for details.
KS_C_5601-1987
raw encoding is available askcs5601-raw
with Encode. SeeEncode::KR for details.
UTF-16 UTF-16BE UTF-16LE
are IANA-registeredcharset
s. See [RFC 2781] for details. Jungshik Shin reports that UTF-16 with a BOM is well accepted by MS IE 5/6 and NS 4/6. Beware however that
UTF-16
support in any software you're going to be using/interoperating with has probably been less tested thenUTF-8
support
UTF-8
coded data seamlessly passes traditional command piping (cat
,more
, etc.) whileUTF-16
coded data is likely to cause confusion (with its zero bytes, for example)
it is beyond the power of words to describe the way HTML browsers encode non-ASCII
form data. To get a general impression, visithttp://www.alanflavell.org.uk/charset/form-i18n.html. While encoding of form data has stabilized forUTF-8
encoded pages (at least IE 5/6, NS 6, and Opera 6 behave consistently), be sure to expect fun (and cross-browser discrepancies) withUTF-16
encoded pages!
The rule of thumb is to useUTF-8
unless you know what you're doing and unless you really benefit from usingUTF-16
.
ISO-IR-165 [RFC1345]VISCIIGB 12345GB 18030 (**) (see links below)EUC-TW (**)
are totally valid encodings but not registered at IANA. The names under which they are listed here are probably the most widely-known names for these encodings and are recommended names.
BIG5PLUS (**)
is a proprietary name.
Microsoft products misuse the following names:
Microsoft extension toEUC-KR
.
Proper names:CP949
,UHC
,x-windows-949
(as used by Mozilla).
Seehttp://lists.w3.org/Archives/Public/ietf-charsets/2001AprJun/0033.html for details.
Encode aliasesKS_C_5601-1987
tocp949
to reflect this common misusage.RawKS_C_5601-1987
encoding is available askcs5601-raw
.
SeeEncode::KR for details.
Microsoft extension toEUC-CN
.
Proper names:CP936
,GBK
.
GB2312
has been registered in theEUC-CN
meaning at IANA. This has partially repaired the situation: Microsoft'sGB2312
has become a superset of the officialGB2312
.
Encode aliasesGB2312
toeuc-cn
in full agreement with IANA registration.cp936
is supported separately.RawGB_2312-80
encoding is available asgb2312-raw
.
SeeEncode::CN for details.
Microsoft extension toBig5
.
Proper name:CP950
.
Encode separately supportsBig5
andcp950
.
Microsoft's understanding ofShift_JIS
.
JIS has not endorsed the full Microsoft standard however. The officialShift_JIS
includes only JIS X 0201 and JIS X 0208 character sets, while Microsoft has always usedShift_JIS
to encode a wider character repertoire. SeeIANA
registration forWindows-31J
.
As a historical predecessor, Microsoft's variant probably has more rights for the name, though it may be objected that Microsoft shouldn't have used JIS as part of the name in the first place.
Unambiguous name:CP932
.IANA
name (also used by Mozilla, and provided as an alias by Encode):Windows-31J
.
Encode separately supportsShift_JIS
andcp932
.
A collection of unique characters. Acharacter set in the strictest sense. At this stage, characters are not numbered.
A character set that is mapped in a way computers can use directly. Many character encodings, including EUC, fall in this category.
An algorithm to map a character set to a byte sequence. You don't have to be able to tell which character set a given byte sequence belongs. 7-bit ISO-2022 is a CES but it cannot be a CCS. EUC is an example of being both a CCS and CES.
has long been used in the meaning ofencoding
, CES.
While the word combinationcharacter set
has lost this meaning in MIME context since [RFC 2130], thecharset
abbreviation has retained it. This is how [RFC 2277] and [RFC 2278] blesscharset
:
This document uses the term "charset" to mean a set of rules formapping from a sequence of octets to a sequence of characters, suchas the combination of a coded character set and a character encodingscheme; this is also what is used as an identifier in MIME "charset="parameters, and registered in the IANA charset registry ... (Notethat this is NOT a term used by other standards bodies, such as ISO).[RFC 2277]
Extended Unix Character. See ISO-2022.
A CES that was carefully designed to coexist with ASCII. There are a 7 bit version and an 8 bit version.
The 7 bit version switches character set via escape sequence so it cannot form a CCS. Since this is more difficult to handle in programs than the 8 bit version, the 7 bit version is not very popular except for iso-2022-jp, thede facto standard CES for e-mails.
The 8 bit version can form a CCS. EUC and ISO-8859 are two examples thereof. Pre-5.6 perl could use them as string literals.
Short forUniversal Character Set. When you say just UCS, it meansUnicode.
ISO/IEC 10646 encoding form: Universal Character Set coded in two octets.
A character set that aims to include all character repertoires of the world. Many character sets in various national as well as industrial standards have become, in a way, just subsets of Unicode.
Short forUnicode Transformation Format. Determines how to map a Unicode character into a byte sequence.
A UTF in 16-bit encoding. Can either be in big endian or little endian. The big endian version is called UTF-16BE (equal to UCS-2 + surrogate support) and the little endian version is called UTF-16LE.
Encode,Encode::Byte,Encode::CN,Encode::JP,Encode::KR,Encode::TW,Encode::EBCDIC,Encode::SymbolEncode::MIME::Header,Encode::Guess
European Computer Manufacturers Associationhttp://www.ecma.ch
ISO-2022
)http://www.ecma.ch/ecma1/STAND/ECMA-035.HTM
The specification of ISO-2022 is available from the link above.
Internet Assigned Numbers Authorityhttp://www.iana.org/
http://www.iana.org/assignments/character-sets
Most of thecanonical names
in Encode derive from this list so you can directly apply the string you have extracted from MIME header of mails and web pages.
International Organization for Standardizationhttp://www.iso.ch/
Request For Comments -- need I say more?http://www.rfc-editor.org/,http://www.ietf.org/rfc.html,http://www.faqs.org/rfcs/
Unicode Consortiumhttp://www.unicode.org/
http://www.unicode.org/glossary/
The glossary of this document is based upon this site.
Contains a lot of useful information, especially gory details of ISO vs. vendor mappings.
http://examples.oreilly.com/cjkvinfo/doc/cjk.inf
Somewhat obsolete (last update in 1996), but still useful. Also try
ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/pdf/GB18030_Summary.pdf
You will find brief info onEUC-CN
,GBK
and mostly onGB 18030
.
And especially its subject 8.
A comprehensive overview of the Korean (KS *
) standards.
A brief description for most of the mentioned CJK encodings is contained inhttp://www.debian.org/doc/manuals/intro-i18n/ch-codes.en.html
CJKV Information Processing
by Ken LundeCJKV Information Processing 1999 O'Reilly & Associates, ISBN : 1-56592-224-7
The modern successor ofCJK.inf
.
Features a comprehensive coverage of CJKV character sets and encodings along with many other issues faced by anyone trying to better support CJKV languages/scripts in all the areas of information processing.
To purchase this book, visithttp://oreilly.com/catalog/9780596514471/ or your favourite bookstore.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.