diff options
author | SADAHIRO Tomoyuki <BQW10602@nifty.com> | 2004-01-16 13:13:00 +0900 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-01-23 13:24:41 +0000 |
commit | a6aa349da2cd706a05b205fa788c278b74c24bdc (patch) | |
tree | b1aa3db7f18a14a566d6b7b7e3df4d47418cd027 /t/uni | |
parent | e84ac4e2e047fe0bbb7415313afdde3e76eafca7 (diff) | |
download | perl-a6aa349da2cd706a05b205fa788c278b74c24bdc.tar.gz |
Re: [perl #24888] chomp ignores utf8
Message-Id: <20040116040355.A849.BQW10602@nifty.com>
Date: Fri, 16 Jan 2004 04:13:00 +0900
p4raw-id: //depot/perl@22196
Diffstat (limited to 't/uni')
-rw-r--r-- | t/uni/chomp.t | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/t/uni/chomp.t b/t/uni/chomp.t new file mode 100644 index 0000000000..1cb3d155c2 --- /dev/null +++ b/t/uni/chomp.t @@ -0,0 +1,64 @@ +#!./perl -w + +BEGIN { + if ($ENV{'PERL_CORE'}){ + chdir 't'; + unshift @INC, '../lib'; + } + require Config; import Config; + if ($Config{'extensions'} !~ /\bEncode\b/) { + print "1..0 # Skip: Encode was not built\n"; + exit 0; + } + if (ord("A") == 193) { + print "1..0 # Skip: EBCDIC\n"; + exit 0; + } + unless (PerlIO::Layer->find('perlio')){ + print "1..0 # Skip: PerlIO required\n"; + exit 0; + } + eval 'use Encode'; + if ($@ =~ /dynamic loading not available/) { + print "1..0 # Skip: no dynamic loading, no Encode\n"; + exit 0; + } +} + +use strict; +use Test::More tests => (4 * 4 * 4) * (3); # (@char ** 3) * (keys %mbchars) + +# %mbchars = (encoding => { bytes => utf8, ... }, ...); +# * pack('C*') is expected to return bytes even if ${^ENCODING} is true. +our %mbchars = ( + 'big-5' => { + pack('C*', 0x40) => pack('U*', 0x40), # COMMERCIAL AT + pack('C*', 0xA4, 0x40) => "\x{4E00}", # CJK-4E00 + }, + 'euc-jp' => { + pack('C*', 0xB0, 0xA1) => "\x{4E9C}", # CJK-4E9C + pack('C*', 0x8F, 0xB0, 0xA1) => "\x{4E02}", # CJK-4E02 + }, + 'shift-jis' => { + pack('C*', 0xA9) => "\x{FF69}", # halfwidth katakana small U + pack('C*', 0x82, 0xA9) => "\x{304B}", # hiragana KA + }, +); + +for my $enc (sort keys %mbchars) { + local ${^ENCODING} = find_encoding($enc); + my @char = (sort(keys %{ $mbchars{$enc} }), + sort(values %{ $mbchars{$enc} })); + + for my $rs (@char) { + local $/ = $rs; + for my $start (@char) { + for my $end (@char) { + my $string = $start.$end; + my $expect = $end eq $rs ? $start : $string; + chomp $string; + is($string, $expect); + } + } + } +} |