So the question remains, is it even possible to create, and install, a module designed for Perl 5.8.3 compatibility, that provides UTF8 functions, and that does not require any non-core modules--and do this with reasonable UTF8-based tests?As I tried to make clear earlier, Test::More::UTF8 is just a helper, which effectively runs the single line of code
BEGIN { binmode Test::More->builder->$_, ':utf8' for qw/failure_output + todo_output output/; }
Here is an SSCCE which I ran in Strawberry Perl v5.8.8, so it should likely be compatible even with Perl v5.8.3 (which I don't have readily available for verification). It shows the wide-character warning if you run it with no command-line arguments, but will not warn if you give it a command line argument of "1" (or any other non-false value). It doesn't use any any non-core modules. All you have to do to make the same code work in general, without command line arguments, is to get rid of the if($ARGV[0]){} wrapper.
use 5.008;
use strict;
use warnings;
use Test::More tests => 1;
use utf8;
use open ':std', ':encoding(UTF-8)';
use Encode;
BEGIN {
if($ARGV[0]) {
binmode Test::More->builder->$_, ':utf8' for qw/failure_output todo_output output/;
}
}
$| = 1;
my $smile = "☺";
diag "This smile $smile will ", ($ARGV[0]?'not ':''), "warn";
is $smile, Encode::decode('UTF-8', "\xE2\x98\xBA"), "equivalent smiles";
__END__
C:> chcp 65001
Active code page: 65001
C:> perl pm11156039_testmoreutf8.pl
1..1
Wide character in print at C:/usr/local/apps/berrybrew/perls/5.8.8_32/perl/lib/Test/Builder.pm line 1275.
# This smile ☺ will warn
ok 1 - equivalent smiles
C:> perl pm11156039_testmoreutf8.pl 1
1..1
# This smile ☺ will not warn
ok 1 - equivalent smiles
(used pre instead of code tags because of unicode characters)
In reply to Re: How to create and install a module compatible with both UTF8 and Perl 5.8.3 without using non-core modules?
by pryrt
in thread How to create and install a module compatible with both UTF8 and Perl 5.8.3 without using non-core modules?
by Polyglot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |