I have some unicode encodings (\ u5315 \ u4e03 \ u58ec \ u4e8c \ u4e0a \ u53b6 \ u4e4b) that I have to convert to the actual characters that they represent.
What is the easiest way to do this?
Can Unicode :: Escape be what you need?
Sometimes I just used pack :
binmode STDOUT, ':utf8'; my $string = '\\u5315\\u4e03\\u58ec\\u4e8c\\u4e0a\\u53b6\\u4e4b'; $string =~ s/\\u(....)/ pack 'U*', hex($1) /eg; print $string;
perl -C -E'say"\x{5315}\x{4e03}\x{58ec}\x{4e8c}\x{4e0a}\x{53b6}\x{4e4b}"'
perl -C -E'say map chr hex, qw(5315 4e03 58ec 4e8c 4e0a 53b6 4e4b)'
use JSON::XS print JSON::XS->new->decode('{"a":"\u5315\u4e03\u58ec\u4e8c\u4e0a\u53b6\u4e4b"}')->{a}