[perl #23428] Somethings rotten in unicode semantics
p4raw-id: //depot/perl@20804
buffer = SvPVutf8(bufsv, blen);
}
else {
- if (DO_UTF8(bufsv))
- sv_utf8_downgrade(bufsv, FALSE);
- buffer = SvPV(bufsv, blen);
+ if (DO_UTF8(bufsv)) {
+ /* Not modifying source SV, so making a temporary copy. */
+ bufsv = sv_2mortal(newSVsv(bufsv));
+ sv_utf8_downgrade(bufsv, FALSE);
+ }
+ buffer = SvPV(bufsv, blen);
}
if (PL_op->op_type == OP_SYSWRITE) {
require "./test.pl";
-plan(tests => 49);
+plan(tests => 51);
$| = 1;
# last test here 49
}
+{
+ # [perl #23428] Somethings rotten in unicode semantics
+ open F, ">a";
+ binmode F, ":utf8";
+ syswrite(F, $a = chr(0x100));
+ is( ord($a), 0x100, '23428 syswrite should not downgrade scalar' );
+ like( $a, qr/^\w+/, '23428 syswrite should not downgrade scalar' );
+}
+
# sysread() and syswrite() tested in lib/open.t since Fcntl is used
END {