develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [perl #21395] rcatline doesn't grok utf8

Thread Previous
From:
Enache Adrian
Date:
February 28, 2003 21:45
Subject:
Re: [perl #21395] rcatline doesn't grok utf8
Message ID:
20030301054634.GA765@ratsnest.hole
On Sat, Mar 01, 2003 at 11:21:34AM +0900, Inaba Hiroto wrote:
> Enache Adrian wrote:
> > Sorry for the hasty patch. I just skipped the scalar-utf8/file-utf8 case.

s/scalar-utf8/scalar-non_utf8/

> I think also scalar-utf8/file-binary case should be considered.
> The recently added macro `sv_catpvn_utf8_upgrade' may be useful.

That was the first case but it isn't handled correctly by my patch.

'$_ . <>' should work just like '$_ = $_ . <>', i.e. if '$_' is utf8 and
'<>' isn't, utf8-encode only the '<>' result and then concatenate them
together.

the following pipelines should have the same output:

$ perl -e 'print chr 256' | perl -e '$_ = chr 256; $_ = $_ . <>; print $_' | od 
$ perl -e 'print chr 256' | perl -e '$_ = chr 256; $_ .= <>; print $_' | od 

The only thing I see is: create a mortal SV, do all the sv_gets() job
on it as it were the actual SV to append to, sv_utf8_upgrade() it and
then concatenate the real & the mortal SV's. That's horrible :-(

(sv_catpvn_utf8_upgrade cannot be used there because sv_gets writes
 directly on the SV's string buffer.)

Regards
Adi

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About