use Encode; my ($unicode_string, $utf16_string); $unicode_string = get_a_unicode_string(); # ^^ this string is a character string internally stored # as UTF-8 $utf16_string = encode('utf16', $unicode_string); # ^^ this string is an 'octet' (byte) string internally # stored as bytes. Each character of the string is stored in # two bytes of $utf_string. # (Also note the presence of a UTF-16 BOM) function_expecting_utf16($utf16_string); #### $"=$,,$_=q>|\p4<6 8p .q>.<4-KI;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/