diff options
author | SADAHIRO Tomoyuki <BQW10602@nifty.com> | 2006-05-15 04:57:28 +0900 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-05-15 08:33:53 +0000 |
commit | 4c5ed6e2fe45844ca952edb0ad5be618e204247b (patch) | |
tree | 13f79404b1e916a7fc9aed964369c986ece9d08d /pp.c | |
parent | 9c8d215a6f7e1098759dbf707ed95f4895bc227c (diff) | |
download | perl-4c5ed6e2fe45844ca952edb0ad5be618e204247b.tar.gz |
strange encodings upsets pp_chr
Message-Id: <20060514195532.5422.BQW10602@nifty.com>
p4raw-id: //depot/perl@28193
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -3367,20 +3367,21 @@ PP(pp_chr) *tmps++ = (char)value; *tmps = '\0'; (void)SvPOK_only(TARG); + if (PL_encoding && !IN_BYTES) { sv_recode_to_utf8(TARG, PL_encoding); tmps = SvPVX(TARG); if (SvCUR(TARG) == 0 || !is_utf8_string((U8*)tmps, SvCUR(TARG)) || - memEQ(tmps, "\xef\xbf\xbd\0", 4)) { - SvGROW(TARG, 3); + UNICODE_IS_REPLACEMENT(utf8_to_uvchr((U8*)tmps, NULL))) { + SvGROW(TARG, 2); tmps = SvPVX(TARG); - SvCUR_set(TARG, 2); - *tmps++ = (U8)UTF8_EIGHT_BIT_HI(value); - *tmps++ = (U8)UTF8_EIGHT_BIT_LO(value); + SvCUR_set(TARG, 1); + *tmps++ = (char)value; *tmps = '\0'; - SvUTF8_on(TARG); + SvUTF8_off(TARG); } } + XPUSHs(TARG); RETURN; } |