# Encode::Unicode
๐Ÿ“ฆ std
ื—ืฆื™ ื”ึพXS ืฉืœ `Encode::Unicode`: ื”ึพcodecs ืฉืœ UTF-16, UTF-32 ื•ึพUCS-2. `Encode/Unicode.pm` is upstreamโ€™s. It creates one blessed hash per encoding - `Name`, `size`, `endian`, `ucs2` - and registers it with `Encode::define_encoding`. The two methods below read those attributes and convert, exactly as `Unicode.xs` does: BOM detection and big-endian fallback for the BOM-less `UTF-16`/`UTF-32`, surrogate pairs, the U+FFFD substitution, and the CHECK handling (croak, warn, leave or consume the source). ```perl use Encode; printf "%vX\n", encode('UTF-16LE', "hi"); # 68.0.69.0 print decode('UTF-16', "\xFE\xFF\0A\0B"), "\n"; # AB (the BOM says big-endian) printf "%vX\n", encode('UTF-16', "\x{1F600}"); # FE.FF.D8.3D.DE.0: BOM, surrogate pair ``` ื”ืงื™ื“ื•ื“ื™ื ื”ื `UTF-16`, `UTF-16BE`, `UTF-16LE`, `UTF-32`, `UTF-32BE`, `UTF-32LE`, `UCS-2BE` ื•ึพ`UCS-2LE`; `Encode` ื˜ื•ืขืŸ ืžื•ื“ื•ืœ ื–ื” ื‘ืคืขื ื”ืจืืฉื•ื ื” ืฉืื—ื“ ืžื”ื ื ื–ื›ืจ ื‘ืฉืžื•. ื–ื”ื• ืžื™ืžื•ืฉ ื ื™ื™ื˜ื™ื‘ื™ ืฉืœ ื—ืฆื™ ื”ึพXS ืฉืœ Encode::Unicode 2.20. ## ื”ื‘ื“ืœื™ื ืžึพupstream ืื™ืŸ. ## ืžื•ื“ื•ืœื™ื - [`Encode::Unicode::UTF7`](Unicode/UTF7.md) - ืงื™ื“ื•ื“ UTF-7 ## ืคื•ื ืงืฆื™ื•ืช ### ืคื•ื ืงืฆื™ื•ืช ืื—ืจื•ืช #### [`decode`](Unicode/decode.md) `$obj->decode($octets [, $check])` - ืื•ืงื˜ื˜ื™ื ืฉืœ UTF-16/32 ืื• UCS-2 ืœืžื—ืจื•ื–ืช ืชื•ื•ื™ื. #### [`encode`](Unicode/encode.md) `$obj->encode($string [, $check])` - ืžื—ืจื•ื–ืช ืชื•ื•ื™ื ืœืื•ืงื˜ื˜ื™ื ืฉืœ UTF-16/32 ืื• UCS-2.