From: Jarkko Hietaniemi Date: Sun, 31 Mar 2002 20:50:23 +0000 (+0000) Subject: Behaviour (make viacode 0xFFFE to return BYTE ORDER MARK, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a23c04e41e8e54701da113d9309ef79fb888afe6;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/charnames.pm b/lib/charnames.pm index 2217f6f..80f31e7 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 "\x{FFFD}" is returned. +If you ask for a character that does not exist, a warning is given +and the Unicode I "\x{FFFD}" is returned. =head1 BUGS diff --git a/lib/charnames.t b/lib/charnames.t index 7b7ad90..42c2205 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"; +