PDA

View Full Version : PERL CGI Unicode programming hint


Drewbert
21st October 2006, 07:57 AM
If you have any PERL CGI programs and ou're looking for a fast way to set their HTML charset output to UTF-8 from the default ISO-8859, it's real simple...

After creating the new CGI object...

my $q = CGI->new();

simply add...


$q->charset('UTF-8');

Once you have done that, the default charset placed in the header is changed for every page that object creates.

Saves having to arse around with header settings in multiple places in your CGI scrpt.

One warning though, you need a fairly recent CGI.pm perl module on your server.

If it doesn't work, download the latest CGI.pm

#cpan

cpan>install CGI

Easy as that.

yanni
21st October 2006, 10:25 AM
It's all Greek to me :)

thegenius1
21st October 2006, 05:53 PM
Its greek to me aswell but i will be sure to document this for future reference , thanks

jose
21st October 2006, 06:24 PM
And in PHP utf8_encode() and utf8_decode()