16 my $s = sprintf "%s", $a;
21 my $s = sprintf "%s", $b;
26 my $s = sprintf "%s%s", $a, $b;
27 is($s, $a.$b, "%s%s a b");
31 my $s = sprintf "%s%s", $b, $a;
32 is($s, $b.$a, "%s%s b a");
36 my $s = sprintf "%s%s", $b, $b;
37 is($s, $b.$b, "%s%s b b");
41 my $s = sprintf "%s$b", $a;
42 is($s, $a.$b, "%sb a");
46 my $s = sprintf "$b%s", $a;
47 is($s, $b.$a, "b%s a");
51 my $s = sprintf "%s$a", $b;
52 is($s, $b.$a, "%sa b");
56 my $s = sprintf "$a%s", $b;
57 is($s, $a.$b, "a%s b");
61 my $s = sprintf "$a%s", $a;
62 is($s, $a.$a, "a%s a");
66 my $s = sprintf "$b%s", $b;
67 is($s, $b.$b, "a%s b");
71 my $s = sprintf "%c", $c;
72 is($s, chr($c), "%c c");
76 my $s = sprintf "%s%c", $a, $c;
77 is($s, $a.chr($c), "%s%c a c");
81 my $s = sprintf "%c%s", $c, $a;
82 is($s, chr($c).$a, "%c%s c a");
86 my $s = sprintf "%c$b", $c;
87 is($s, chr($c).$b, "%cb c");
91 my $s = sprintf "%s%c$b", $a, $c;
92 is($s, $a.chr($c).$b, "%s%cb a c");
96 my $s = sprintf "%c%s$b", $c, $a;
97 is($s, chr($c).$a.$b, "%c%sb c a");
101 my $s = sprintf "$b%c", $c;
102 is($s, $b.chr($c), "b%c c");
106 my $s = sprintf "$b%s%c", $a, $c;
107 is($s, $b.$a.chr($c), "b%s%c a c");
111 my $s = sprintf "$b%c%s", $c, $a;
112 is($s, $b.chr($c).$a, "b%c%s c a");
116 # 20010407.008 sprintf removes utf8-ness
117 $a = sprintf "\x{1234}";
118 is((sprintf "%x %d", unpack("U*", $a), length($a)), "1234 1",
120 $a = sprintf "%s", "\x{5678}";
121 is((sprintf "%x %d", unpack("U*", $a), length($a)), "5678 1",
123 $a = sprintf "\x{1234}%s", "\x{5678}";
124 is((sprintf "%x %x %d", unpack("U*", $a), length($a)), "1234 5678 2",
125 '\x{1234}%s \x{5678}');
129 # check that utf8ness doesn't "accumulate"
134 $sprintf = sprintf "%s%s", $w, "$w\x{100}";
135 is(substr($sprintf,0,2), $w, "utf8 echo");
137 $sprintf = sprintf "%s%s", $w, "$w\x{100}";
138 is(substr($sprintf,0,2), $w, "utf8 echo echo");