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.
authorKarl Williamson <khw@cpan.org>
Mon, 24 Nov 2014 04:44:17 +0000 (21:44 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 24 Nov 2014 17:50:26 +0000 (10:50 -0700)
commit374aed2060f1b45b00ae9ad47fb986b4619492c7
treee093b2dcd5a861d61bf4ba7992aec921993305b0
parent896eff3c48ae9560ce70fb8a9e729558e65592da
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.
lib/_charnames.pm