Thanks Andy but I can't use that. The script needs to run to generate part of the content for the index page of a site so speed is an issue (loading all those modules may take too long for me).
I found something that works...kinda:
my $title = pack('C*', unpack('U*', $rawTitle));
$rawTitle is the string with the odd characters and $title is the string I need to display.
The follwing accomplishes what I want:
Code:
use utf8;
my $rawTitle = "RÈGLEMENT SUR LA CRÉATION D'UNE ZONE SANS FRÊNES";
my $title = pack('C*', unpack('U*', $rawTitle));
This will make $title = "RÈGLEMENT SUR LA CRÉATION D'UNE ZONE SANS FRÊNES"
However (there just had to be a however...)
I get the value of $rawTitle by running a few Regular Expressions on a value I obtain by using:
Code:
my $ua = new LWP::UserAgent;
my $res = $ua->request(GET $url);
my $content = $res->content; For some reason, data obtained this way will not encode/decode (or pack/unpack) properly.
I think it has to do with the fact that $rawTitle is treated as UTF8 when I hard code it in the script (because of the use utf8; directive).
I need someway to convert the content I get from the $ua->request(GET $url); into something that displays properly.