summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-03-09 13:50:57 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-09 13:50:57 +0000
commit52d2e0f43e4c92315f9f6c027571388b7bc65ff5 (patch)
tree9d3a5ecb667da98fcf89f05c2b945974ed5cf5ed /toke.c
parent5460b889677b9f352c882dbcd4ad4470b8281664 (diff)
downloadperl-52d2e0f43e4c92315f9f6c027571388b7bc65ff5.tar.gz
From Inaba Hiroto: DATA wasn't properly utf8ed
under 'use encoding'. p4raw-id: //depot/perl@18865
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 5214989d59..4e5a977844 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;
}