tlpkg UTF-8 Umlauts Problem

Masamichi Hosoda trueroad at trueroad.jp
Wed Mar 24 11:31:06 CET 2021


>> Am 24.03.21 um 10:36 schrieb Siep Kroonenberg:
>>> Can you try a different terminal font?
>> 
>> Dear all,
>> 
>> just to add: I noticed the same thing after installation. Changing the
>> font does not solve this as the encoding seems to be wrong as Hartmut
>> said.
> 
> Hi all,
> 
> How about this patch?
> 
> ```
> --- install-tl.org
> +++ install-tl
> @@ -189,6 +189,10 @@
>      &create_uninstaller
>      &maybe_make_ro
>    ));
> +} else {
> +  binmode (STDIN, ':utf8');
> +  binmode (STDOUT, ':utf8');
> +  binmode (STDERR, ':utf8');
>  }
>  
>  use strict;
> @@ -2496,11 +2500,8 @@
>    if (!defined($::LOGFILE)) {
>      # no -logfile option; nothing written yet
>      $::LOGFILENAME = "$vars{'TEXDIR'}/install-tl.log";
> -    if (open(LOGF,">$::LOGFILENAME")) {
> +    if (open(LOGF,">:utf8", $::LOGFILENAME)) {
>        $::LOGFILE = \*LOGF;
> -      if (win32) {
> -        binmode (LOGF, ':utf8');
> -      }
>        foreach my $line(@::LOGLINES) {
>          print $::LOGFILE "$line";
>        }
> ```

If you prefer to support non-UTF-8 consoles, here is a patch for that.
However, the log file is outputed in UTF-8.

```
--- install-tl.org
+++ install-tl
@@ -157,13 +157,28 @@
 use TeXLive::TLDownload;
 use TeXLive::TLPaper;
 
-if (win32) {
+use Encode::Alias;
+eval {
   require Encode::Locale;
   Encode::Locale->import ();
-  binmode (STDIN, ':encoding(console_in)');
-  binmode (STDOUT, ':encoding(console_out)');
-  binmode (STDERR, ':encoding(console_out)');
+  debug("Encode::Locale is loaded.\n");
+};
+if ($@) {
+  if (win32) {
+    die ("For Windows, Encode::Locale is required.\n");
+  }
 
+  debug("Encode::Locale is not found. Assuming all encodings are UTF-8.\n");
+  Encode::Alias::define_alias('locale' => 'UTF-8');
+  Encode::Alias::define_alias('locale_fs' => 'UTF-8');
+  Encode::Alias::define_alias('console_in' => 'UTF-8');
+  Encode::Alias::define_alias('console_out' => 'UTF-8');
+}
+binmode (STDIN, ':encoding(console_in)');
+binmode (STDOUT, ':encoding(console_out)');
+binmode (STDERR, ':encoding(console_out)');
+
+if (win32) {
   require TeXLive::TLWinGoo;
   TeXLive::TLWinGoo->import( qw(
     &is_vista
@@ -2496,11 +2511,8 @@
   if (!defined($::LOGFILE)) {
     # no -logfile option; nothing written yet
     $::LOGFILENAME = "$vars{'TEXDIR'}/install-tl.log";
-    if (open(LOGF,">$::LOGFILENAME")) {
+    if (open(LOGF,">:utf8", $::LOGFILENAME)) {
       $::LOGFILE = \*LOGF;
-      if (win32) {
-        binmode (LOGF, ':utf8');
-      }
       foreach my $line(@::LOGLINES) {
         print $::LOGFILE "$line";
       }
```

  Masamichi Hosoda <trueroad at trueroad.jp>


More information about the tex-live mailing list.