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

Re: "use v5.36.0" should imply UTF-8 encoded source

Thread Previous | Thread Next
From:
Dan Book
Date:
July 30, 2021 18:40
Subject:
Re: "use v5.36.0" should imply UTF-8 encoded source
Message ID:
CABMkAVVV6yXB1r4Men-bstHggJYKwS76aLpuE6aiB37vOt_6fQ@mail.gmail.com
On Fri, Jul 30, 2021 at 2:34 PM Andrew Hewus Fresh <andrew@afresh1.com>
wrote:

> On Fri, Jul 30, 2021 at 10:45:53AM -0400, Ricardo Signes wrote:
> > Porters,
> >
> > I propose that "use v5.36.0" should imply that the source code is,
> subsequently, UTF-8 encoded.
> >
> > Currently, I advise the following boilerplate:
> > use v5.34.0;
> > use warnings;
> > use utf8;
>
> Tom recommends a bit more boilerplate than that, although the only
> one (other than fatal warnings) that hasn't been mentioned is:
>
> use open qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
>
> https://perldoc.perl.org/perlunicook#%E2%84%9E-0:-Standard-preamble
>
> And wow would I like to get rid of the "wide character in output" from
> my `perl -E` one-liners (I know, `perl -C -E`, but boilerplate!).
>

This is not feasible because it affects STDIN/STDOUT/STDERR globally and so
will break the assumptions of any code in the process that uses them.
Lexically setting defaults for only handles only opened in that scope may
be feasible for use VERSION (the equivalent of the same declaration without
:std), but since such filehandles can still be passed around that is also
something that would need a "risk assessment".

-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