[Koha-patches] [PATCH] (bug #3412) fix double encoded guided report

Ricardo Dias Marques lists at ricmarques.net
Wed Jul 15 11:48:28 CEST 2009


Hi Frédéric (and others)

On 15-Jul-2009, Frédéric DEMIANS <f.demians at tamil.fr> wrote:

>>> -    binmode STDOUT, ':utf8';
[snip]
>
> Those utf8 issues are very strange. I don't understand the logic. I
> confirm I had also to suppress this line to avoid corrupted reports. My
> 'feeling' is that binmode should be avoided at all. If characters are
> correctly handled in Perl script, explicitly specifying output file
> encoding is not required anymore. If you began doing binmode on files,
> you also need to encode-decode strings, and at the end of the day you
> get Nahuel double-encoding problems.

I admit that I don't have any experience with UNICODE when related to
Perl programming, but the Perldoc page for binmode mentions a
":encoding(utf8)" for the second argument ("LAYER") for binmode
function calls, that may be a better alternative to ":utf8" in this
case:

binmode - perldoc.perl.org
http://perldoc.perl.org/functions/binmode.html

Quoting the relevant paragraph from that page:

" 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. "


On a related note that may or not be relevant, I enjoyed reading the
following article by Jeremy Zawodny:

The Perl UTF-8 and utf8 Encoding Mess (by Jeremy Zawodny)
http://jeremy.zawodny.com/blog/archives/010546.html


I hope this may help in some way.


Cheers,
Ricardo Dias Marques
lists AT ricmarques DOT net
Installation Guide for Installing Koha 3 on openSUSE 11
http://wiki.koha.org/doku.php?id=opensuse_11.0



More information about the Koha-patches mailing list