I'm having troubles debugging a Perl program where variable names (or hash key) are UTF-8 strings. The program compiles ok (and runs) but whenever I want to debug it, the debugger is quite unhappy with the variable/hash key names if I need to use them.
Here is a (very simple) MWE:
use strict;use utf8;use warnings qw(FATAL utf8);use open qw(:std :encoding(UTF-8));use charnames qw(:full :short);my $unité = 125;my %hash = ( 'Quantité' => 18 );printf "%d\n", $unité*$unité;printf "%d\n", $hash{Quantité};
When running, no problem :
$ perl test.pl 1562518
But when debugging, the debugger is very sad :
$ perl -d test.plLoading DB routines from perl5db.pl version 1.77Editor support available.Enter h or 'h h' for help, or 'man perldebug' for more help. HistFile = '/home/XXX/.perldb.hist'Éxécution afterinitmain::(test.pl:10): my $unité = 125; DB<100> nmain::(test.pl:11): printf "%d\n", $unité*$unité; DB<100> p $unitéUnrecognized character \xC3; marked by <-- HERE after T} $unit<-- HERE near column 120 at (eval 10)[/usr/lib64/perl5/5.38/perl5db.pl:742] line 2. at (eval 10)[/usr/lib64/perl5/5.38/perl5db.pl:742] line 2. eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $^D = $^D | $DB::db_stop;print {$DB::OUT} $unité;' called at /usr/lib64/perl5/5.38/perl5db.pl line 742 DB::eval called at /usr/lib64/perl5/5.38/perl5db.pl line 3451 DB::DB called at test.pl line 11
So, how can I access an UTF8-named variable (same problem with the hash key)?