Re: Recap on utf8 encoding issues and PerlIO patch

William McKee <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
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
Petal.pm.diff-2.15 (text/plain, 471 B)
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";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.