* Michael G Schwern <[EMAIL PROTECTED]> [2008-02-24 05:40]: > I just merged together a number of tickets having to do with > Test::More not liking wide characters.
Good. Now you can close them, since it’s not your bug. It’s the main program’s responsibility to set the encoding on its handles sensibly. It is not your module doing something wrong in its `print`s; it is your users not setting up their environment properly. > use 5.008; > use strict; > use warnings; use open ':std', ':locale'; > use Test::More tests => 1; > > my $uni = "\x{11e}"; > > ok( $uni eq $uni, "Testing $uni" ); > > __END__ > 1..1 > Wide character in print at lib/Test/Builder.pm line 1252. ^^^^^^ after the above patch, gone > ok 1 - Testing Ğ > > I know almost nothing about Unicode. How do I make this Just > Work? Is it safe to just set binmode to always be ':utf8' if > perl > 5.8? No! If that were the case, why is that not the default? The right thing is for the caller to have his locale set properly, so that if his terminal expects Latin-1 or KOI-8R or UTF-8, the above L<open> incantation will transcode output to Latin-1 or KOI-8R or UTF-8 as appropriate. This also ensures that if the tests try to output a character that the terminal cannot render, the user will get a warning and the character will be output as an `\x` escape. If you blithely assume that their terminal can render UTF-8, and it cannot, you are likely to throw garbage at the terminal that it will interpret as control sequences, screwing up the display entirely. Unfortunately, a properly set locale was not the rule, at least a few years ago; Perl 5.8.0 did the moral equivalent of that `open` automatically, and it caused a lot of problems for users when distros like RedHat started going all-UTF8 in earnest. I have no idea whether the situation is better now… although one would hope it is. Anyway, if I’ve set up my STDFOO handles to transcode to a different encoding, I certainly wouldn’t want Test::More to blithely stomp all over that configuration. *That* *would* be a bug… and squarely *your* bug. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>