This is intentional. The output by Data::Dumper
is intended to produce the same data structure when eval
uated as Perl code. To limit the effect of character encodings, non-ASCII characters will be dumped using escapes. In addition to that, it's sensible to set $Data::Dumper::Useqq = 1
so that any unprintable characters are dumped using escapes.
Data::Dumper
isn't really meant as a way to display data structures – if you have specific formatting requirements, just write the necessary code yourself. For example
use utf8;
use feature 'say';
open my $out, ">:utf8", $filename or die "Can't open $filename: $!";
my %hash = (
bárewørdş => '–Uni·code–',
);
say { $out } "{";
for my $key (sort keys %hash) {
say { $out } " $key: $hash{$key}";
}
say { $out } "}";
produces
{
bárewørdş: –Uni·code–
}