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
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@lists.koha.org [mailto:koha-devel-bounces@lists.koha.org] De la part de Rick Welykochy Envoyé : 14 décembre 2008 14:52 À : koha-devel@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@lists.koha.org http://lists.koha.org/mailman/listinfo/koha-devel
Rick -- That is just one form that happens to be used for existing filehandles. You can also find similar code in "open" statements (see rebuild_zebra.pl) and the same code in different forms like: binmode(STDOUT,":utf8"); We should setting it (or something like it) where needed. --Joe On Sun, Dec 14, 2008 at 2:51 PM, Rick Welykochy <rick@praxis.com.au> wrote:
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<http://lists.koha.org/mailman/listinfo/koha-devel>
Sébastien Nadeau wrote:
" 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.
Joe Atzberger wrote:
That is just one form that happens to be used for existing filehandles. You can also find similar code in "open" statements (see rebuild_zebra.pl) and the same code in different forms like: binmode(STDOUT,":utf8");
We should setting it (or something like it) where needed.
Exactly where is it needed? Is it required for web page output to stdout? Is it required when Koha creates a CSV file as output? Is the situation as it stands a bug? From what M.Nadeau indicates, we should be using :encoding(utf8), which ensures that our UTF-8 output is valid. It is another form of turning on warnings. ":utf8" is not enough. The problem with UTF-8 and non-Latin character sets in general is that most of the developers never venture into accented character sets and thus support for UTF-8 has been late in coming to Koha. We are lucky to have many non-English language contributors who can keep the project "honest" about character encoding. I must admit that I myself do not test or develop any software using UTF-8, unless perhaps it is turned on by default. I certainly would not be aware if non-English alphabets were being broken by anything I did to the software. This concerns me and I would like to ensure we do as much as possible in the Koha software to ensure we get it right. cheers rickw -- _________________________________ Rick Welykochy || Praxis Services It isn't pollution that's harming the environment. It's the impurities in our air and water that are doing it. -- Al Gore, Vice President
Rick Welykochy a écrit :
Exactly where is it needed?
Is it required for web page output to stdout?
If i'm not mistaken, HTML::Template::Pro take cares of that (it was not the case of HTML::Template)
Is it required when Koha creates a CSV file as output?
yes. -- Paul POULAIN http://www.biblibre.com Expert en Logiciels Libres pour l'info-doc Tel : (33) 4 91 81 35 08
participants (4)
-
Joe Atzberger -
paul POULAIN -
Rick Welykochy -
Sébastien Nadeau