Skip Menu |

This queue is for tickets about the Map-Tube-CLI CPAN distribution.

Report information
The Basics
Id: 123467
Status: resolved
Priority: 0/
Queue: Map-Tube-CLI

People
Owner: MANWAR [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.32
Fixed in: 0.33



Subject: map-tube does not work with non-ascii chars
Currently map-tube does not know anything about encodings, and fails if the user tries to use a start/end station with non-ascii characters: $ map-tube --map=Berlin --start=Kurfürstendamm --end=Schönfließ --preferred Map::Tube::get_node_by_name(): ERROR: Invalid Station Name [Kurfürstendamm]. (status: 101) file /opt/perl-5.26.1/lib/site_perl/5.26.1/Map/Tube/CLI.pm on line 302 ... Unfortunately perl's @ARGV is not automatically correctly decoded, and most getopt modules does not seem to do this either. A possible solution is to use Encode::Locale's decode_argv function rather early in the script, and along with it, make also sure that STDOUT+STDERR are correctly encoded: ... BEGIN { if (-t) { require Encode::Locale; Encode::Locale::decode_argv(); binmode(STDOUT, ":encoding(console_out)"); binmode(STDERR, ":encoding(console_out)"); } } use Map::Tube::CLI; ... This feels a little hacky, but with this change I get the desired result: $ map-tube --map=Berlin --start=Kurfürstendamm --end=Schönfließ --preferred Kurfürstendamm (U9), Zoologischer Garten (U9), Hansaplatz (S2, S8), Turmstr. (S2, S8), Birkenstr. (S8), Westhafen (S8), Wedding (U9), Gesundbrunnen (U9), Bornholmer Str. (U9), Pankow (S41/S42, U9), Pankow-Heinersdorf (S41/S42), Blankenburg (S1, S2, S25, S41/S42), Mühlenbeck-Mönchsmühle (S1, S2, S25, S8, S9), Schönfließ (S2, S8, S9) That was with a utf8 locale and an utf8 xterm. It also seems to work with a latin1 locale; tried using LC_ALL=de_DE.iso88591 xterm& and entering the command again. Regards, Slaven
Hi @SREZIC, Thanks for raising the issue and providing the solution as well. Much appreciated. Best Regards, Mohammad S Anwar
Released the patch.