diff options
author | Karl Williamson <khw@khw-desktop.(none)> | 2010-06-30 14:42:59 -0600 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2010-07-04 21:43:41 +0100 |
commit | 232cbbee26bf464eff66953e51b99f7293f3d676 (patch) | |
tree | fd66880c1628183213a8002d3b22d340663761ad /lib/charnames.t | |
parent | da85ecb8100a34ccc17636776871fafc7a2853bf (diff) | |
download | perl-232cbbee26bf464eff66953e51b99f7293f3d676.tar.gz |
Allow defining custom charnames to ordinals
This adds the ability of a user to create a custom alias that maps to a
numeric ordinal value, instead of an official Unicode name.
The number of hashes went up so that is better to refer to them by a
name than a number, so I renamed them.
Also, viacode will return any defined user's alias for an otherwise
unamed code point.
This change is principally so that private use characters can be named
so it is more convenient to use them in Perl.
Diffstat (limited to 'lib/charnames.t')
-rw-r--r-- | lib/charnames.t | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/charnames.t b/lib/charnames.t index 3f6e5d9544..8df4d700f0 100644 --- a/lib/charnames.t +++ b/lib/charnames.t @@ -50,6 +50,23 @@ EOE is ($res, 'b', "Verify that can redefine a standard alias"); } +{ + + use charnames ':full', ":alias" => { mychar1 => 0xE8000, + mychar2 => 983040, # U+F0000 + mychar3 => "U+100000", + myctrl => 0x80, + }; + is ("\N{mychar1}", chr(0xE8000), "Verify that can define hex alias"); + is (charnames::viacode(0xE8000), "mychar1", "And that can get the alias back"); + is ("\N{mychar2}", chr(0xF0000), "Verify that can define decimal alias"); + is (charnames::viacode(0xF0000), "mychar2", "And that can get the alias back"); + is ("\N{mychar3}", chr(0x100000), "Verify that can define U+... alias"); + is (charnames::viacode(0x100000), "mychar3", "And that can get the alias back"); + is (charnames::viacode(0x80), "myctrl", "Verify that can name a nameless control"); + +} + my $encoded_be; my $encoded_alpha; my $encoded_bet; |