#!/usr/bin/perl my $utf16 = pack('U',hex(shift)); my $utf8; print("Before echo, length of $utf16: ", length $utf16, "\n"); chomp($utf16 = `echo $utf16`); print("After echo, ength of $utf16: ", length $utf16, "\n"); $utf8 .= sprintf("\\0x%x",ord($_)) foreach(split(/|/,$utf16)); print("$utf8\n"); exit;