From 7d59b7e40bca518078f3e97c802950b76d52efa2 Mon Sep 17 00:00:00 2001 From: Nick Ing-Simmons Date: Sat, 9 Dec 2000 19:47:30 +0000 Subject: Make print, syswrite, send, readline, getc honour utf8-ness of PerlIO. (sysread, recv and write i.e. formats still to do...) Allow :utf8 or :bytes in PerlIO_apply_layers() so that open($fh,">:utf8","name") etc. work. - "applying" those just sets/clears the UTF8 bit of the top layer, so no extra overhead is involved. Tweak t/comp/require.t to add a 'use bytes' to permit its dubious writing of BOM to a non-utf8 stream. Add initial io/utf8.t Fix SvPVutf8() - sv_2pv() was not expecting to be called with something that was already SvPOK() - (we just fossiked with SvUTF8 bit). Fix that and also just use the SvPV macro in sv_2pvutf8() to avoid the issue/overhead. p4raw-id: //depot/perlio@8054 --- doio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'doio.c') diff --git a/doio.c b/doio.c index 901ca718d0..d8168e1636 100644 --- a/doio.c +++ b/doio.c @@ -1148,12 +1148,14 @@ Perl_do_print(pTHX_ register SV *sv, PerlIO *fp) } /* FALL THROUGH */ default: -#if 0 - /* XXX Fix this when the I/O disciplines arrive. XXX */ - if (DO_UTF8(sv)) - sv_utf8_downgrade(sv, FALSE); -#endif - tmps = SvPV(sv, len); + if (PerlIO_isutf8(fp)) { + tmps = SvPVutf8(sv, len); + } + else { + if (DO_UTF8(sv)) + sv_utf8_downgrade(sv, FALSE); + tmps = SvPV(sv, len); + } break; } /* To detect whether the process is about to overstep its -- cgit v1.2.1