# 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.