From: Jarkko Hietaniemi Date: Sun, 9 Mar 2003 13:50:57 +0000 (+0000) Subject: From Inaba Hiroto: DATA wasn't properly utf8ed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52d2e0f43e4c92315f9f6c027571388b7bc65ff5;p=p5sagit%2Fp5-mst-13.2.git From Inaba Hiroto: DATA wasn't properly utf8ed under 'use encoding'. p4raw-id: //depot/perl@18865 --- diff --git a/MANIFEST b/MANIFEST index 6fec033..11ea10c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -261,6 +261,7 @@ ext/Encode/t/big5-hkscs.utf test data ext/Encode/t/CJKT.t test script ext/Encode/t/Encode.t test script ext/Encode/t/Encoder.t test script +ext/Encode/t/enc_data.t test script for utf8 DATA ext/Encode/t/enc_eucjp.t test script ext/Encode/t/enc_module.enc test data for t/enc_module.t ext/Encode/t/enc_module.t test script diff --git a/ext/Encode/MANIFEST b/ext/Encode/MANIFEST index 2705308..0eb87ed 100644 --- a/ext/Encode/MANIFEST +++ b/ext/Encode/MANIFEST @@ -62,6 +62,7 @@ t/big5-eten.enc test data t/big5-eten.utf test data t/big5-hkscs.enc test data t/big5-hkscs.utf test data +t/enc_data.t test script for utf8 DATA t/enc_eucjp.t test script t/enc_module.enc test data for t/enc_module.t t/enc_module.t test script diff --git a/ext/Encode/t/enc_data.t b/ext/Encode/t/enc_data.t new file mode 100644 index 0000000..f47d083 --- /dev/null +++ b/ext/Encode/t/enc_data.t @@ -0,0 +1,24 @@ +use encoding 'euc-jp'; +use Test::More tests => 1; + +my @a; + +while () { + chomp; + tr/¤¡-¤ó¥¡-¥ó/¥¡-¥ó¤¡-¤ó/; + push @a, $_; +} + +SKIP: { + skip("pre-5.8.1 does not do utf8 DATA", 1) if $] < 5.008001; + ok(@a == 3 && + $a[0] eq "¥³¥ì¥ÏDATA¤Õ¤¡¤¤¤ë¤Ï¤ó¤É¤ë¥Î¤Æ¤¹¤È¥Ç¥¹¡£" && + $a[1] eq "ÆüËܸ쥬¥Á¥ã¥ó¥ÈÊÑ´¹¥Ç¥­¥ë¥«" && + $a[2] eq "¥É¥¦¥«¥Î¤Æ¤¹¤È¥ò¥·¥Æ¥¤¥Þ¥¹¡£", + "utf8 (euc-jp) DATA") +} + +__DATA__ +¤³¤ì¤ÏDATA¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Î¥Æ¥¹¥È¤Ç¤¹¡£ +ÆüËܸ줬¤Á¤ã¤ó¤ÈÊÑ´¹¤Ç¤­¤ë¤« +¤É¤¦¤«¤Î¥Æ¥¹¥È¤ò¤·¤Æ¤¤¤Þ¤¹¡£ diff --git a/toke.c b/toke.c index 5214989..4e5a977 100644 --- a/toke.c +++ b/toke.c @@ -4188,8 +4188,29 @@ Perl_yylex(pTHX) } #endif #ifdef PERLIO_LAYERS - if (UTF && !IN_BYTES) - PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8"); + if (!IN_BYTES) { + if (UTF) + PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8"); + else if (PL_encoding) { + SV *name; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(sp); + EXTEND(SP, 1); + XPUSHs(PL_encoding); + PUTBACK; + call_method("name", G_SCALAR); + SPAGAIN; + name = POPs; + PUTBACK; + PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, + Perl_form(aTHX_ ":encoding(%"SVf")", + name)); + FREETMPS; + LEAVE; + } + } #endif PL_rsfp = Nullfp; }