[tex-live] bug in TeX Live Utility
mpg at elzevir.fr
Mon Jul 13 20:20:14 CEST 2009
Norbert Preining a écrit :
> On Sun, 12 Jul 2009, Karl Berry wrote:
>> Commenting out
>> binmode(STDOUT, ":utf8");
>> in tlmgr.pl 'fixes' this problem, but I've no idea how it should be
>> solved correctly.
>> Evidently that binmode is causing double encoding. I don't remember why
>> it's there.
I tend to think that the binmode here is not the cause. The cause it that Perl
somehow gets utf8 strings without properly marking them as utf8. If all utf8
strings are known to be utf8 by Perl, nothing will get
> Honestly, if *ANYONE* here can make sense of all the :FOOBAR in perl
> and can explain me how I get:
> - guaranteed utf8 encoded files saved (saving tlpdb)
> - reading from tlpdb in the right encoding
> - output to stdout in the encoding that is the "correct" one
> - and probably some other cases I forgot
> then I would happily fix that, but AFAIR the binmode didn't come with
> some reason.
I generaly use
use utf8; # script encoding
use open IO => ':utf8'; # default encoding for files we open later
binmode(STDIN, ":utf8"); # these 3 fh are allready opened with
binmode(STDOUT, ":utf8"); # a possibly wrong (tipically latin1) encoding
binmode(STDERR, ":utf8"); # so reset them to something deterministic
and have no encoding problem at all, as long as everything (the script itself,
stdin, sdtout, stderr, any files the script reads from or writes to) if utf-8.
If for some reason I want to read or write a file using, say latin1, I do
open my $fh, '<:encoding(iso-8859-1)', $filename;
(s/</>/ for writing obsiously).
The "use open IO => ':utf8';" line may not work with older perls or perls
compiled without PerlIO. In this case, it is necessary to explicitly say
open my $fh, '<:encoding(utf8)', $filename;
for each file containing non-ascii and encoded in utf-8 that we want to open.
More information about the tex-live