[Koha-devel] binmode in pler scripts for utf-8 support

Sébastien Nadeau Sebastien.Nadeau at bibl.ulaval.ca
Mon Dec 15 16:07:03 CET 2008


Hi,

Indeed, it's important to do so when utf8 encoded text is going to be written to a filehandle. For example, when extracting data from an utf8 database like MySQL and writing it to a file, or when reading from an utf8 encoded file.

" To mark FILEHANDLE as UTF-8, use :utf8  or :encoding(utf8) . :utf8  just marks the data as UTF-8 without further checking, while :encoding(utf8)  checks the data for actually being valid UTF-8. More details can be found in PerlIO::encoding. "

This quote from the binmode perldoc suggests that one must take good care about what is written to the filehandle when the ":uft8" layer is used. It it's not well formed uft-8, the result might end up in something unexpected.

Sébastien

 

> -----Message d'origine-----
> De : koha-devel-bounces at lists.koha.org 
> [mailto:koha-devel-bounces at lists.koha.org] De la part de Rick 
> Welykochy
> Envoyé : 14 décembre 2008 14:52
> À : koha-devel at lists.koha.org
> Objet : [Koha-devel] binmode in pler scripts for utf-8 support
> 
> Hi all,
> 
> I ran across this bit of randomness today:
> 
>     binmode STDOUT, ":utf8";
> 
> It occurs in only three perl scripts in Koha:
> 
> ./circ/ysearch.pl
> ./misc/sax_parser_test.pl
> ./reports/guided_reports.pl
> 
> Should this binmode setting be executed in all of our perl 
> scripts to provide correct utf-8 support?
> 
> If not, why not?
> 
> 
> cheers
> rickw
> 
> 
> 
> --
> _________________________________
> Rick Welykochy || Praxis Services
> 
> We are ready for any unforeseen event that may or may not occur.
>       -- Al Gore, Vice President
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha.org
> http://lists.koha.org/mailman/listinfo/koha-devel
> 



More information about the Koha-devel mailing list