[Petal] Recap on utf8 encoding issues and PerlIO patch

William McKee william at knowmad.com
Fri Jan 21 05:18:44 GMT 2005


On Thu, Jan 20, 2005 at 05:59:30PM +0000, Bruno Postle wrote:
> ..it seems to persuade some browsers to intrepret the document
> properly.

Thanks, nice tip.


> ..and this explains why this line works if $encoding is utf8, since
> "<:utf8" happens to be valid syntax.

Actually, I had to make some further modifications to my patch as some
templates which had encoded values after using tidy were causing
repeated errors like the following which completely tied up my system:

 utf8 "\xB9" does not map to Unicode at
 /usr/local/lib/perl5/site_perl/5.8.6/Petal.pm line 589, <FP> line 54.

This patch uses the "<:utf8" format for utf8 and the
"<:encoding($encoding)" method for other charsets, this seems to work. I
only tested this patch with latin1.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com
-------------- next part --------------
581c581,586
< 	open FP, "<:$encoding", "$file_path" || die 'Cannot read-open $file_path';
---
>   if (lc $encoding eq 'utf8') {
>     open FP, "<:$encoding", "$file_path" or die "Cannot read-open $file_path: $!";
>   }
>   else {
>     open FP, "<:encoding($encoding)", "$file_path" or die "Cannot read-open $file_path: $!";
>   }
585c590
< 	open FP, "<$file_path" || die 'Cannot read-open $file_path';
---
> 	open FP, "<$file_path" or die "Cannot read-open $file_path";


More information about the Petal mailing list