Perl プログラマの頭の中。Perl, CGI, JavaScript, etc…

Output utf8 string to STDERR when using Data::Dumper or Smart::Comments

Perl’s Data::Dumper and Smart::Comments are very useful for developing. But when process non ASCII data, even if you are processing them with utf8 pragma and having specified the encoding of STDERR, these modules output the character’s unicode (hexadecimal number) in the messages instead of the message itself. This problem will be solved by using $SIG{__WARN__} hook.

Problem when processing UTF-8 strings

When process non ASCII data, in my case Japanese, if I specify the encoding of STDERR, it works for MY error messages in the main program. But the output of Smart::Comments and Data::Dumper remains expressed as hex numbers.