develooper Front page | perl.perl5.porters | Postings from January 2022

Short character name clashes

From:
David Cantrell
Date:
January 27, 2022 12:22
Subject:
Short character name clashes
Message ID:
e125dab6-b891-8011-ed84-475395d9a515@cantrell.org.uk
Yesterday we briefly discussed on IRC an issue I found with `use 
charnames`. If you want to avoid being excessively wordy like with 
`\N{HEBREW LETTER ALEF}` you can ask charnames.pm for some nice short 
aliases. For example:

   use charnames qw(hebrew);
   say "\N{alef}";

Hebrew isn't special of course, you can do this for all kinds of 
scripts. You can even do it for multiple scripts at the same time:

   use charnames qw(greek runic);
   say "\N{gamma}";
   say "\N{yr}";

But there's a problem. Several scripts have letters with the same name. 
Hebrew and Arabic, for example, both have a letter 'alef', so what 
happens here?

   use charnames qw(arabic hebrew);
   say "\N{alef}";

As it happens, you seem to always get HEBREW LETTER ALEF, because 
Hebrew's codepoints come before Arabic's. But I think it would be a good 
idea to at least warn the user of the potential for confusion like this, 
so I've created a pull request:
   https://github.com/Perl/perl5/pull/19369

It's only a preliminary draft and definitely needs work, in particular 
the text I've put in the warning itself needs improvement.

-- 
David Cantrell



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About