develooper Front page | perl.perl5.porters | Postings from December 2000

Re: UTF8 flag and sv_utf8_upgrade

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
December 12, 2000 14:28
Subject:
Re: UTF8 flag and sv_utf8_upgrade
Message ID:
E145xsi-0005C5-00@roam1
Simon Cozens <simon@cozens.net> writes:
>On Tue, Dec 12, 2000 at 07:22:16PM +0000, Nick Ing-Simmons wrote:
>> None the less there are a few spots which do this kind of thing: 
>> 
>>  if (extra_data_is_utf8)
>>   {
>>    sv_utf8_upgrade(sv);
>>   } 
>>  add_extra_stuff.
>>  SvUTF8_on(sv); 
>
>I don't understand the problem you have with that. If you're adding UTF8
>data to a non-UTF8 string, you *have* to upgrade the non-UTF8 string.

Yes then you HAVE to set SvUTF8_on AS WELL. Because sv_utf8_upgrade
will not have done that if the non-UTF8 string was all ASCII.

>
>> It seems to me that if one does not _care_ then one does not call 
>> upgrade in the first place.
>
>Doesn't care about what? Getting sane results back? One *must* call
>upgrade if one has UTF8 data. Period.

We are in VIOLENT AGREEMENT ;-)

As far as I can tell anytime one would call sv_utf8_upgrade it is because
you know you have UTF8 data. So the normal paradigm is thus

   sv_utf8_upgrade(sv);
   SvUTF8_on(sv);

Which seems repeditive, but perhaps you want to add 
  
   Really_UTF8(sv);
   I_Mean_UTF8_perl_I_really_really_do(sv);
   Leave_UTF8_on(sv);

as well ;-) - (all of which would of couse walk along the string 
one more time checking for coding violations.)



  


-- 
Nick Ing-Simmons


Thread Previous | Thread Next


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