I am puzzled at the following difference.
$str="\xd6\xd0";
decode("GBK",$str);
vs.
$str="d6d0";
@list=map "\\x".$_,unpack("(a2)*", $str);
$str=join "", @list;
decode("GBK",$str);
Why in the first case, it worked to print out the character, while in the second case, it is not working? How can I make it to work in the latter case?
Many thanks.
If you’re trying to turn
"d6d0"into"\xd6\xd0", you wantpack 'H*':joindoes not interpret escape sequences, it just concatenates strings.