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}";
}
}
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
=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
$| = 1;
-print "1..37\n";
+print "1..38\n";
use charnames ':full';
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";
}
print "ok 37\n";
}
+print "not " unless charnames::viacode(0xFFFE) eq "BYTE ORDER MARK";
+print "ok 38\n";
+