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:
Felipe Gasper
Date:
August 3, 2021 22:45
Subject:
Re: "use v5.36.0" should imply UTF-8 encoded source
Message ID:
F46E0E12-08C2-4EF1-B696-4D64BDF09CF8@felipegasper.com

> On Aug 3, 2021, at 17:35, L A Walsh <Astara@tlinx.org> wrote:
> 
> On 2021/07/30 07:45, Ricardo Signes wrote:
>> Porters,
>> 
>> I propose that "use v5.36.0" should imply that the source code is, subsequently, UTF-8 encoded.
> 
> How about -CL, as that seems to do the same and work with most of
> the cases others brought up...
> ---
> Though, the attached seems to work with or without that switch, not
> exactly sure why though (has utf8 in the source)...

It works because of character encoding bugs in the Perl builtins that you’re using. See CPAN’s Sys::Binmode for the fix.

-F

> #!/usr/bin/perl 
> use warnings; use strict;
> sub P(@);
> if (0) {
>    eval 'use P';
> } else  {
>    eval ' sub P(@) { printf @_ if @_; print "\n"; } ';
> }
> 
> my $x="é";
> my $pi="Π";
> my $u8tmp="𝐓𝐌𝐏";
> my $tmp="/tmp";
> my $epee="épée";
> P "x=%s, u8tmp=%s", $x, $u8tmp;
> my $newtmp="$tmp/$u8tmp";
> if ( ! -d $newtmp) {
>    mkdir $newtmp or die P "mkdir %s returned %s", $newtmp, $!;
> }
> system("touch \"$newtmp/$x\" ");
> chdir $newtmp;
> system("touch \"$newtmp/$epee\" ");
> my $dot=".";
> opendir my $dh,$dot or die P "opendir of %s failed: %s", $dot,$!;
> while (defined($_=readdir($dh))) {
>    P "found %s", $_;
> };                                                 
> closedir $dh || die P "closedir failed with %s",$!;
> #if (-e $tmp) {
> #    rmdir "$tmp" || die P "rmdir of %s: %s", $tmp, $!
> #}


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