Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created July 25, 2011 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchristian/1103863 to your computer and use it in GitHub Desktop.
Save wchristian/1103863 to your computer and use it in GitHub Desktop.

äöü
use 5.010;
use Test::More;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 7, 'normal';
}
use utf8::all;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'utf8';
}
use autodie;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'autodie on';
}
no autodie;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'autodie off';
}
done_testing();
$ENV{PERL_UNICODE} = 'DAS';
system( $^X, "utf8_autodie_env.t" );
delete $ENV{PERL_UNICODE};
$ENV{PERLIO} = ':utf8';
system( $^X, "utf8_autodie_env.t" );
__END__
D:\utf8>perl utf8_autodie.t
ok 1 - normal
ok 2 - utf8
not ok 3 - autodie on
# Failed test 'autodie on'
# at utf8_autodie.t line 24.
# got: '7'
# expected: '4'
ok 4 - autodie off
1..4
ok 1 - with_env normal
not ok 2 - with_env autodie on
# Failed test 'with_env autodie on'
# at utf8_autodie_env.t line 16.
# got: '7'
# expected: '4'
ok 3 - with_env no autodie off
1..3
# Looks like you failed 1 test of 3.
# Looks like you failed 1 test of 4.
use 5.010;
use Test::More;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'with_env normal ';
}
use autodie;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'with_env autodie on';
}
no autodie;
{
open my $fh, '<', 'text';
my @utf8_lines = <$fh>;
is length $utf8_lines[1], 4, 'with_env no autodie off';
}
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment