Reputation: 79
I have strings like: "Film-DVD \x{bb}Once / The Swell Season (Collector's Edition\x{ab} John Carney" which are the result of Data::Dumper.
Now I want the hex-values \x{bb}, \x{ab} to be replaced with corresponding characters » and «.
I already tried:
$a =~ s/\\x\{(.{2})\}/chr(hex($1))/eg;
But this returns me "Film-DVD �Once / The Swell Season (Collector's Edition� John Carney"
Do you have any ideas what i could do?
Upvotes: 0
Views: 88
Reputation: 385789
The code you posted is correct.
The problem appears to be that you forgot to tell Perl to encode your output. This is normally done using
use open ':std', ':encoding(UTF-8)';
Upvotes: 4