develooper Front page | perl.perl5.porters | Postings from April 2021

Re: Perl 7: Fix string leaks?

Thread Previous | Thread Next
From:
Dan Book
Date:
April 1, 2021 03:05
Subject:
Re: Perl 7: Fix string leaks?
Message ID:
CABMkAVWOjV3cbnsPEiXV+OjUPixbei0GK=vYcZ5v_Pfu-ubb3g@mail.gmail.com
On Wed, Mar 31, 2021 at 10:56 PM Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

> Dan
>
> > This is intentional; the names of these two features are not related.
>
> > "use utf8" means that the source code is assumed to be UTF-8, and thus
> implicitly decoded from it - this may or may not require upgraded string
> storage.
>
> -----------------------------------------------------
> use strict;
> use warnings;
> use utf8;
> use Encode 'encode', 'decode';
> use Devel::Peek;
>
> # ASCII range
> my $text = 'abc';
>
> # 0
> print "A. " . (utf8::is_utf8($text) ? 1 : 0) . "\n";
> Devel::Peek::Dump $text;
> print "\n";
> --------------------------------------------------------
>
> If first example was 1, what problem occur?
>
> In other words, 'abc' is interpreted as UTF-8 and utf8 flag turn on.
>

It would not be a problem, and indeed Perl could decide to do this for any
reason. It chooses not to currently because downgraded string operations
are more efficient.

-Dan

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