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

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

Thread Previous | Thread Next
From:
Tom Molesworth via perl5-porters
Date:
August 2, 2021 17:30
Subject:
Re: "use v5.36.0" should imply UTF-8 encoded source
Message ID:
CAGXhHdnej37ADaEM3YD0EuH0zswzeQHSB18s3oL5shtCaZOBgg@mail.gmail.com
My apologies, hit send too soon:

On Tue, 3 Aug 2021 at 01:23, Tom Molesworth <tom@deriv.com> wrote:

> On Tue, 3 Aug 2021 at 01:17, Felipe Gasper <felipe@felipegasper.com>
> wrote:
>
>>
>> -----
>> use v5.36;
>> use Encode;
>> print Encode::encode_utf8('Hello, world!');
>> -----
>>
>> … and any ensuing explanation will have to discuss character encoding,
>> and the fact that Perl can’t tell text from bytes. Right away this simple
>> example draws attention to one of Perl’s more frustration-prone qualities.
>>
>> Respectfully, I just can’t see how this improves the language, and I’m
>> surprised more folks aren’t voicing similar thoughts. I’d love to be wrong;
>> I guess we’ll see.
>>
>
> In core, the official answer is "use utf8" with "binmode":
>
> https://perldoc.perl.org/perluniintro
>
> Outside core Perl, one of the commonly shared guides is
>
>
... this summary by tchrist:

https://stackoverflow.com/a/6163129

A general mantra of "transcode at the edges" is something I personally find
more helpful than adding encode/decode operations throughout the core of
the code.

Enabling utf8 by default (lexical scope) conflicts with our inability to
enable the `encoding(UTF-8)` binmode by default (global scope).

Nice as utf8-everywhere might be - for some use-cases, at least - I don't
think there has been any viable option provided to resolve this?

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