in reply to UTF encoded subroutine names
The difference between the two symbols you've posted here is that Σ is U+03A3 GREEK CAPITAL LETTER SIGMA, while ∫ is U+222B INTEGRAL. If you use ∑ instead, that's U+2211 N-ARY SUMMATION, the same error happens, and if you use ʃ, U+0283 LATIN SMALL LETTER ESH, the error doesn't happen. As per Identifier parsing, identifiers under use utf8; must start with a character matching (?[ ( \p{Word} & \p{XID_Start} ) + [_] ]), and as per perluniprops, items from the Unicode block "Mathematical Operators" don't match that rule. Unfortunately, these symbols aren't quite equivalent of course, but if you want to use them as names for Perl subroutines, you'll probably have to stick with the lookalikes. Update: I also find this very useful: Unicode Utilities: Character Properties.
use warnings; use 5.028; use experimental 'regex_sets'; use open qw/:std :utf8/; use charnames ':full'; my $PERL_IDENT_RE = qr/ (?[ ( \p{Word} & \p{XID_Start} ) + [_] ]) (?[ ( \p{Word} & \p{XID_Continue} ) ]) * /x; for my $c ( 0x2211, 0x03A3, 0x222B, 0x0283 ) { printf "%s U+%04X %s %s\n", chr($c), $c, charnames::viacode($c), chr($c) =~ /\A$PERL_IDENT_RE\z/ ? "matches" : "doesn't match"; }
Output:
∑ U+2211 N-ARY SUMMATION doesn't match Σ U+03A3 GREEK CAPITAL LETTER SIGMA matches ∫ U+222B INTEGRAL doesn't match ʃ U+0283 LATIN SMALL LETTER ESH matches
Update 2: BTW, also: Ʃ U+01A9 LATIN CAPITAL LETTER ESH matches.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF encoded subroutine names
by pme (Monsignor) on Jan 30, 2021 at 10:55 UTC | |
by haukex (Archbishop) on Jan 30, 2021 at 10:57 UTC | |
by pme (Monsignor) on Jan 31, 2021 at 11:15 UTC | |
by haukex (Archbishop) on Jan 31, 2021 at 15:52 UTC |