This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
charnames: Don't return UTF-8 unless have to.
A Latin-1 range character doesn't require UTF-8 to be represented. Not
using UTF-8 speeds things up a lot. This commit changes the return to
be UTF-8 only if necessary. This could be because
1) the character isn't representable except in UTF-8; or
2) we are being called at runtime and the character isn't ASCII-range.
The only way we can currently guarantee that an upper-Latin1
character will be treated with Unicode rules is to make it UTF-8
(the Unicode bug). The compile-time code (in toke.c) knows how to
properly deal with non-UTF-8 upper Latin1 range characters.
The utf8::downgrade introduced in this commit is temporary. Future
commits will change things so that there is no need for it.