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

Re: UTF8 flag and sv_utf8_upgrade

Thread Previous | Thread Next
Nick Ing-Simmons
December 12, 2000 15:33
Re: UTF8 flag and sv_utf8_upgrade
Message ID:
Simon Cozens <> writes:
>On Tue, Dec 12, 2000 at 10:26:45PM +0000, Nick Ing-Simmons wrote:
>> >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.
>sv_utf8_upgrade is really "upgrade if necessary". But yes, in practise it's
>"I'm about to do UTF8 things with this string". You want something like this:

Which is what I said at the begining.
The question is then will that be sub-optimal for _any_ existing use,
or do we need a new function, or argument to the exiting one, or ...

>        SvPVX(sv) = (char*)bytes_to_utf8((U8*)s, &len);
>        SvCUR(sv) = len - 1;
>        SvLEN(sv) = len; /* No longer know the real size. */
>-       SvUTF8_on(sv);
>        Safefree(s); /* No longer using what was there before. */
>     }
>+    SvUTF8_on(sv);
> }
Nick Ing-Simmons

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About