From: SADAHIRO Tomoyuki Date: Mon, 12 Jan 2004 11:19:37 +0000 (+0900) Subject: Re: [perl #24846] [PATCH] Apparent utf8 bug in join() in 5.8.[012] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4803c42e84cae1aa5a416a4f8c6f80f7d37e49f;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #24846] [PATCH] Apparent utf8 bug in join() in 5.8.[012] Message-Id: <20040112111007.EB69.BQW10602@nifty.com> p4raw-id: //depot/perl@22117 --- diff --git a/doop.c b/doop.c index dc64c45..ffa1d1b 100644 --- a/doop.c +++ b/doop.c @@ -670,6 +670,10 @@ Perl_do_join(pTHX_ register SV *sv, SV *del, register SV **mark, register SV **s } sv_setpv(sv, ""); + /* sv_setpv retains old UTF8ness [perl #24846] */ + if (SvUTF8(sv)) + SvUTF8_off(sv); + if (PL_tainting && SvMAGICAL(sv)) SvTAINTED_off(sv); diff --git a/t/op/join.t b/t/op/join.t index 0f849fd..a1cc607 100755 --- a/t/op/join.t +++ b/t/op/join.t @@ -1,6 +1,6 @@ #!./perl -print "1..14\n"; +print "1..18\n"; @x = (1, 2, 3); if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";} @@ -65,3 +65,29 @@ if ($f eq 'baeak') {print "ok 6\n";} else {print "# '$f'\nnot ok 6\n";} print "ok 14\n"; } +{ # [perl #24846] $jb2 should be in bytes, not in utf8. + my $b = "abc\304"; + my $u = "abc\x{0100}"; + + sub join_into_my_variable { + my $r = join("", @_); + return $r; + } + + my $jb1 = join_into_my_variable("", $b); + my $ju1 = join_into_my_variable("", $u); + my $jb2 = join_into_my_variable("", $b); + my $ju2 = join_into_my_variable("", $u); + + print "not " unless unpack('H*', $jb1) eq unpack('H*', $b); + print "ok 15\n"; + + print "not " unless unpack('H*', $ju1) eq unpack('H*', $u); + print "ok 16\n"; + + print "not " unless unpack('H*', $jb2) eq unpack('H*', $b); + print "ok 17\n"; + + print "not " unless unpack('H*', $ju2) eq unpack('H*', $u); + print "ok 18\n"; +}