in reply to Re^3: How do I convert a sequence of hexes (D0 D6) to Chinese characters (中)?
in thread How do I convert a sequence of hexes (D0 D6) to Chinese characters (中)?
Sorry, my last post was unclear. I meant the program by grantm. Here is a clarified version:
I am very grateful for your help. However, when I run the program below by grantm, I do not get the character '中', but rather the non-sensical "Σ╕ˇ". Any idea of what is going wrong? Thanks. (I have the East Asian language pack installed, so it is not simply that.)
use Encode qw(decode);
my $ascii_hex = 'D6D0'; # continue for as many bytes as required
my $bytes = pack('H*', $ascii_hex);
my $character_string = decode('gb2312', $bytes);
print $character_string, "\n";