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

Short character name clashes

David Cantrell
January 27, 2022 12:22
Short character name clashes
Message ID:
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 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:

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About