Hi! Thank you for using Data::Printer and for taking the time to file this issue, I really appreciate it. Also, apologies for not replying sooner. I haven't been paying close attention to RT after the issue tracker move to Github.
Though I am tempted to treat this as a bug, I think David is right: we cannot assume an encoding of the strings being dumped, and guessing the encoding is something remarkably hard to do. Finally, the output does not necessarily go to STDERR, and we'd have to check the encoding of every possible target.
If you feel this is wrong and can provide a good patch for it that is able to properly address those concerns, or even if you just want to comment on the issue, feel free to reply!
Meanwhile, the current Data::Printer (0.99_X on CPAN, and on github's master branch) lets you escape characters at will, effectively avoiding the warning:
$ perl -Ilib -MDDP -Mutf8 -E 'my $name = q(Василий); p $name'
Wide character in print at lib/Data/Printer.pm line 128.
"Василий"
$ perl -Ilib -MDDP -Mutf8 -E 'my $name = q(Василий); p $name, escape_chars => q(nonascii)'
"\x{412}\x{430}\x{441}\x{438}\x{43b}\x{438}\x{439}"
(note: no warning above)
$ perl -Ilib -MDDP -Mutf8 -E 'my $name = q(Василий); p $name, escape_chars => q(nonlatin1), unicode_charnames => 1'
"\N{CYRILLIC CAPITAL LETTER VE}\N{CYRILLIC SMALL LETTER A}\N{CYRILLIC SMALL LETTER ES}\N{CYRILLIC SMALL LETTER I}\N{CYRILLIC SMALL LETTER EL}\N{CYRILLIC SMALL LETTER I}\N{CYRILLIC SMALL LETTER SHORT I}"
(also no warnings)
Hope this helps!
garu
On Tue Nov 18 08:39:58 2014, Flimm wrote:
Show quoted text> Try this instead:
>
> use utf8;
> use DDP;
> binmode STDERR, ":encoding(UTF-8)";
> my $name = 'Василий';
> p $name;
>
> This how I would expect DDP to behave, as it's the same as with the
> built-in print.
>
> On Wed Mar 26 09:44:18 2014, v197@mail.ru wrote:
> >
> > Hi!
> > Code:
> > use utf8;
> > use DDP;
> > my $name = 'Василий';
> > p $name;
> > Result:
> > Wide character in print at
> > /usr/local/share/perl/5.14.2/Data/Printer.pm line 190.
> > "Василий"
> >
> > Version:
> > Data-Printer v 0.35
> >
> > --
> > С уважением, Владислав