diff options
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1169,13 +1169,12 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp) /* FALL THROUGH */ default: if (PerlIO_isutf8(fp)) { - tmps = SvPVutf8(sv, len); - } - else { - if (DO_UTF8(sv)) - sv_utf8_downgrade(sv, FALSE); - tmps = SvPV(sv, len); + if (!SvUTF8(sv)) + sv_utf8_upgrade(sv = sv_mortalcopy(sv)); } + else if (DO_UTF8(sv)) + sv_utf8_downgrade((sv = sv_mortalcopy(sv)), FALSE); + tmps = SvPV(sv, len); break; } /* To detect whether the process is about to overstep its |