X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperluniintro.pod;h=68f8a01534ab424da1f652018d98eb4d146641f3;hb=824215e2e3b067efbb0104afd616d77cb9526d1a;hp=9b447caab961766e0eeb34426de87d046addbf5a;hpb=1d9bf7bbf0578bdc2583de01f734aade7fa3b931;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perluniintro.pod b/pod/perluniintro.pod index 9b447ca..68f8a01 100644 --- a/pod/perluniintro.pod +++ b/pod/perluniintro.pod @@ -790,6 +790,15 @@ C, and C, available from CPAN. If you have the GNU recode installed, you can also use the Perl frontend C for character conversions. +The following are fast conversions from ISO 8859-1 (Latin-1) bytes +to UTF-8 bytes, the code works even with older Perl 5 versions. + + # ISO 8859-1 to UTF-8 + s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg; + + # UTF-8 to ISO 8859-1 + s/([\xC2\xC3])([\x80-\xBF])/chr(ord($1)<<6&0xC0|ord($2)&0x3F)/eg; + =head1 SEE ALSO L, L, L, L, L, L,