summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-10-31 14:44:33 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-10-31 14:44:33 +0000
commit121910a497e33cc9235ecb1b0488ff5200159bc4 (patch)
tree00034df2cba6330202b1d350cfcdc8aa828c089f /pp.c
parent4bdee82d7bc2074b4348e7a8af9486f836481a0a (diff)
downloadperl-121910a497e33cc9235ecb1b0488ff5200159bc4.tar.gz
Extend the effect of the encoding pragma to chr() and ord().
TODO: regex literals, reentrancy problems with the utf8 and charnames pragmas. p4raw-id: //depot/perl@12790
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index 1c323f783d..d6d0534817 100644
--- a/pp.c
+++ b/pp.c
@@ -3033,8 +3033,16 @@ PP(pp_ord)
SV *argsv = POPs;
STRLEN len;
U8 *s = (U8*)SvPVx(argsv, len);
+ SV *tmpsv;
+
+ if (PL_encoding && !DO_UTF8(argsv)) {
+ tmpsv = sv_2mortal(newSVsv(argsv));
+ s = (U8*)Perl_sv_recode_to_utf8(aTHX_ tmpsv, PL_encoding);
+ argsv = tmpsv;
+ }
XPUSHu(DO_UTF8(argsv) ? utf8_to_uvchr(s, 0) : (*s & 0xff));
+
RETURN;
}
@@ -3063,6 +3071,8 @@ PP(pp_chr)
*tmps++ = value;
*tmps = '\0';
(void)SvPOK_only(TARG);
+ if (PL_encoding)
+ Perl_sv_recode_to_utf8(aTHX_ TARG, PL_encoding);
XPUSHs(TARG);
RETURN;
}