RETPUSHUNDEF;
}
else {
- if (utfcurlen) {
+ if (utfcurlen)
sv_pos_u2b(sv, &pos, &rem);
- SvUTF8_on(TARG);
- }
tmps += pos;
sv_setpvn(TARG, tmps, rem);
+ if (utfcurlen)
+ SvUTF8_on(TARG);
if (repl)
sv_insert(sv, pos, rem, repl, repl_len);
else if (lvalue) { /* it's an lvalue! */
"Attempt to use reference as lvalue in substr");
}
if (SvOK(sv)) /* is it defined ? */
- (void)SvPOK_only(sv);
+ (void)SvPOK_only_UTF8(sv);
else
sv_setpvn(sv,"",0); /* avoid lexical reincarnation */
}
-print "1..125\n";
+print "1..130\n";
#P = start of string Q = start of substr R = end of substr S = end of string
$a = "abcdefgh";
ok 124, sub { shift }->(substr($a, 0, 4, "xxxx")) eq 'abcd';
ok 125, $a eq 'xxxxefgh';
+
+# utf8 sanity
+{
+ my $x = substr("a\x{263a}b",0);
+ ok 126, length($x) eq 3;
+ $x = substr($x,1,1);
+ ok 127, $x eq "\x{263a}";
+ ok 128, length($x) eq 1;
+ substr($x,0,1) = "abcd";
+ ok 129, $x eq "abcd";
+ ok 130, length($x) eq 4;
+}