in reply to How to to get chinese charactor from unicode?

You're trying to convert a Perl string literal to a string. To do that, use perl:
$s = '\u805a\u5408\u6216\u8be6\u7ec6'; $s =~ s/u(\w\w\w\w)/x{$1}/g; $s = eval qq{"$s"}; print($s);

Alternatively, you could interpret the original string yourself

$s = '\u805a\u5408\u6216\u8be6\u7ec6'; $s =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/ge; print($s);

Replies are listed 'Best First'.
Re^2: How to to get chinese charactor from unicode?
by ikegami (Patriarch) on Mar 02, 2007 at 06:57 UTC

    I wasn't too happy with the second snippet. It had no way of escaping \. This is a fix:

    my $out = ''; for ($in) { /\G ([^\\]+) /xgc && ( $out .= $1 ); /\G \\u([0-9A-Fa-f]{4})/xgc && do { $out .= chr(hex($1)); redo; }; /\G \\(.) /xgc && do { $out .= $1; redo; }; }