diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-31 14:44:33 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-10-31 14:44:33 +0000 |
commit | 121910a497e33cc9235ecb1b0488ff5200159bc4 (patch) | |
tree | 00034df2cba6330202b1d350cfcdc8aa828c089f /pp.c | |
parent | 4bdee82d7bc2074b4348e7a8af9486f836481a0a (diff) | |
download | perl-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.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; } |