Encode::Unicode#
חצי ה־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).
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- קידוד UTF-7
פונקציות#
פונקציות אחרות#
decode#
$obj->decode($octets [, $check]) - אוקטטים של UTF-16/32 או UCS-2 למחרוזת תווים.
encode#
$obj->encode($string [, $check]) - מחרוזת תווים לאוקטטים של UTF-16/32 או UCS-2.