From: Jarkko Hietaniemi Date: Tue, 17 Oct 2000 14:11:31 +0000 (+0000) Subject: On output try to downgrade to bytes, croak if impossible, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b3603a49f6eac34b6cdb154bf3bd8a8f5240085;p=p5sagit%2Fp5-mst-13.2.git On output try to downgrade to bytes, croak if impossible, from Simon Cozens. This means that outputting >255 UTF8 is impossible. Consider this as a strong incentive to get the I/O disciplines implemented. p4raw-id: //depot/perl@7355 --- diff --git a/doio.c b/doio.c index 2f78bc9..52dfd6d 100644 --- a/doio.c +++ b/doio.c @@ -1186,6 +1186,9 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp) } /* FALL THROUGH */ default: + /* XXX Fix this when the I/O disciplines arrive. XXX */ + if (DO_UTF8(sv)) + sv_utf8_downgrade(sv, FALSE); tmps = SvPV(sv, len); break; } diff --git a/pod/perldiag.pod b/pod/perldiag.pod index c4d2654..480ab84 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3822,6 +3822,10 @@ but in actual fact, you got So put in parentheses to say what you really mean. +=item Wide character in %s + +(F) Perl met a wide character (>255) when it wasn't expecting one. + =item write() on closed filehandle %s (W closed) The filehandle you're writing to got itself closed sometime diff --git a/sv.c b/sv.c index 21b6758..b795b29 100644 --- a/sv.c +++ b/sv.c @@ -2448,8 +2448,13 @@ Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok) if (!utf8_to_bytes((U8*)c, &len)) { if (fail_ok) return FALSE; - else - Perl_croak(aTHX_ "big byte"); + else { + if (PL_op) + Perl_croak(aTHX_ "Wide character in %s", + PL_op_desc[PL_op->op_type]); + else + Perl_croak(aTHX_ "Wide character"); + } } SvCUR(sv) = len - 1; SvUTF8_off(sv);