Fix for 20010407.008 sprintf removes utf8-ness.
Jarkko Hietaniemi [Thu, 16 Aug 2001 11:46:02 +0000 (11:46 +0000)]
p4raw-id: //depot/perl@11691

pp.c
t/op/misc.t

diff --git a/pp.c b/pp.c
index ee9d47e..c0148b3 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2933,6 +2933,8 @@ PP(pp_sprintf)
     dSP; dMARK; dORIGMARK; dTARGET;
     do_sprintf(TARG, SP-MARK, MARK+1);
     TAINT_IF(SvTAINTED(TARG));
+    if (DO_UTF8(*(MARK+1)))
+       SvUTF8_on(TARG);
     SP = ORIGMARK;
     PUSHTARG;
     RETURN;
index e7f1623..e55e18a 100755 (executable)
@@ -724,9 +724,14 @@ sub DESTROY {
 EXPECT
 Bar=ARRAY(0x...)
 ########
-printf "%x %x", unpack "U*", sprintf "\x{1234}%s", "\x{5678}"
-EXPECT
-1234 5678
+# 20010407.008 sprintf removes utf8-ness
+$a = sprintf "\x{1234}";
+printf "%x %d\n", unpack("U*", $a), length($a);
+$a = sprintf "\x{1234}%s", "\x{5678}";
+printf "%x %x %d\n", unpack("U*", $a), length($a);
+EXPECT
+1234 1
+1234 5678 2
 ########
 # keep this last - doesn't seem to work otherwise?
 eval "a.b.c.d.e.f;sub"