diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-31 20:50:23 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-31 20:50:23 +0000 |
commit | a23c04e41e8e54701da113d9309ef79fb888afe6 (patch) | |
tree | ddbe8a2b3337b8379be052ad2687ea07bfd9254a /lib | |
parent | 4a66ea5a3f06b7d87684264c54e3021d40406dc8 (diff) | |
download | perl-a23c04e41e8e54701da113d9309ef79fb888afe6.tar.gz |
Behaviour (make viacode 0xFFFE to return BYTE ORDER MARK,
make viacode no-allocatedcode to return the 0xFFFD) tweaks,
respective test and doc tweaks.
p4raw-id: //depot/perl@15637
Diffstat (limited to 'lib')
-rw-r--r-- | lib/charnames.pm | 14 | ||||
-rw-r--r-- | lib/charnames.t | 8 |
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/charnames.pm b/lib/charnames.pm index 2217f6fa2a..80f31e7eba 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -208,8 +208,11 @@ sub viacode if ($txt =~ m/^$hex\t\t(.+)/m) { return $viacode{$hex} = $1; + } elsif ($hex eq 'FFFE') { + return $viacode{$hex} = "BYTE ORDER MARK"; } else { - return; + carp "Unknown charcode '$hex'"; + return "\x{FFFD}"; } } @@ -254,8 +257,8 @@ charnames - define character names for C<\N{named}> string literal escapes. use charnames qw(cyrillic greek); print "\N{sigma} is Greek sigma, and \N{be} is Cyrillic b.\n"; - print charname::viacode(0x1234); # prints "ETHIOPIC SYLLABLE SEE" - printf "%04X", charname::vianame("GOTHIC LETTER AHSA"); # prints "10330" + print charnames::viacode(0x1234); # prints "ETHIOPIC SYLLABLE SEE" + printf "%04X", charnames::vianame("GOTHIC LETTER AHSA"); # prints "10330" =head1 DESCRIPTION @@ -397,9 +400,8 @@ will also give a warning about being deprecated. =head1 ILLEGAL CHARACTERS -If you ask for a character that is illegal (like the byte order mark -U+FFFE, or the U+FFFF) does not exist, a warning is given and the -special Unicode I<replacement character> "\x{FFFD}" is returned. +If you ask for a character that does not exist, a warning is given +and the Unicode I<replacement character> "\x{FFFD}" is returned. =head1 BUGS diff --git a/lib/charnames.t b/lib/charnames.t index 7b7ad90640..42c2205713 100644 --- a/lib/charnames.t +++ b/lib/charnames.t @@ -12,7 +12,7 @@ BEGIN { $| = 1; -print "1..37\n"; +print "1..38\n"; use charnames ':full'; @@ -137,7 +137,8 @@ sub to_bytes { print "not " unless charnames::viacode(0x1234) eq "ETHIOPIC SYLLABLE SEE"; print "ok 17\n"; - print "not " if defined charnames::viacode(0x0590); # unused Hebrew + # Unused Hebrew. + print "not " unless charnames::viacode(0x0590) eq chr(0xFFFD); print "ok 18\n"; } @@ -216,3 +217,6 @@ print "ok 33\n"; print "ok 37\n"; } +print "not " unless charnames::viacode(0xFFFE) eq "BYTE ORDER MARK"; +print "ok 38\n"; + |