[OAI-implementers] Perl & Unicode/UTF-8

Tim Brody tim@tim.brody.btinternet.co.uk
Wed, 8 Jan 2003 17:17:06 -0000


(in reply to earlier posts on problems with Perl & UTF8)

Perl 5.8 has much improved support for unicode, including the ability to
"convert" from one mapping to another, e.g.

#!/usr/bin/perl

binmode(STDIN, ":encoding(latin1)");
binmode(STDOUT, ":utf8");

while(<>) {
    print $_;
}

__END__

Will read in latin1, and output in UTF-8.

It also checks that what you output is in UTF-8 - any non-UTF-8 data
generates warnings.

(See the core Encode module for how to convert abitrary strings.)

All the best,
Tim Brody