```{index} single: encode (Encode::Unicode) ``` ```{index} single: Encode::Unicode::encode ``` # encode `$obj->encode($string [, $check])` - a character string to UTF-16/32 or UCS-2 octets. With no fixed byte order (`UTF-16`, `UTF-32`) the output starts with a big-endian BOM. Characters above U+FFFF become surrogate pairs in UTF-16; in UCS-2, and anything above U+10FFFF, they become U+FFFD - or croak with `FB_CROAK`, or warn with `FB_WARN`. A partial UTF-8 character at the end croaks when CHECK has `DIE_ON_ERR` or `LEAVE_SRC`.