Skip to content

Commit

Permalink
Avoid use of an undocumented charnames API
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Apr 20, 2012
1 parent a755b3f commit 5cff688
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Encode/JP/Mobile/Charnames.pm
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
package Encode::JP::Mobile::Charnames; package Encode::JP::Mobile::Charnames;
use strict; use strict;
use warnings; use warnings;
use charnames ();
use bytes (); use bytes ();
use File::ShareDir 'dist_file'; use File::ShareDir 'dist_file';
use Carp; use Carp;
Expand All @@ -14,6 +13,12 @@ our @EXPORT_OK = qw( unicode2name unicode2name_en vianame );


my $name2unicode; my $name2unicode;


{
use charnames ':full';
BEGIN { *_def_translator = $^H{charnames} }
}


sub import { sub import {
# for perl < 5.10 # for perl < 5.10
if ($charnames::hint_bits) { if ($charnames::hint_bits) {
Expand Down Expand Up @@ -67,14 +72,14 @@ sub _unicode_translator {
} }
} }
else { else {
return charnames::charnames($name); return _def_translator($name);
} }
} }


# pictograms are only in the above 0xFF area. # pictograms are only in the above 0xFF area.
sub _bytes_translator { sub _bytes_translator {
my $name = shift; my $name = shift;
return charnames::charnames($name); return _def_translator($name);
} }


sub vianame { sub vianame {
Expand Down

0 comments on commit 5cff688

Please sign in to comment.