develooper Front page | perl.perl5.porters | Postings from October 2017

Re: Unicode operators

Thread Previous | Thread Next
From:
Tony Cook
Date:
October 25, 2017 00:56
Subject:
Re: Unicode operators
Message ID:
20171025005609.GI18693@mars.tony.develop-help.com
On Sun, Oct 22, 2017 at 05:40:01PM +0100, Zefram wrote:
> Philip R Brenan wrote:
> >Please give me some idea of how to add these operators to Perl for real?
> 
> You'd have to start by solving the issue of source encoding.  In theory
> some non-ASCII characters can already be used as part of Perl source,
> in string literals and in identifiers, but this doesn't work properly.
> The treatment of such characters, their semantic effect, depends on the
> way in which the source is encoded, even when perl can correctly decode
> source files to the same character sequence.

C<use utf8;> does just that, and code like:

 $ ./perl -Ilib -Mutf8 -le '$π = 3.14159265; print $π'
 3.14159265

behaves sensibly. including rejecting non-id characters:

$ ./perl -Ilib -Mutf8 -le '$‗ = 3.14159265; print $‗'
Unrecognized character \x{2017}; marked by <-- HERE after $<-- HERE near column 2 at -e line 1.

and retains backward compatibility.

Tony

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