From: Jarkko Hietaniemi Date: Fri, 2 Nov 2001 02:14:46 +0000 (+0000) Subject: Make encoding and charnames pragmas coexist. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bfa383d613055a7a37cd2a7c710949ec437a40af;p=p5sagit%2Fp5-mst-13.2.git Make encoding and charnames pragmas coexist. p4raw-id: //depot/perl@12804 --- diff --git a/lib/charnames.pm b/lib/charnames.pm index 787ecf9..70d6d17 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -45,7 +45,7 @@ sub charnames { my $fname = substr $txt, $off[0] + 2, $off[1] - $off[0] - 2; die "Character 0x$hex with name '$fname' is above 0xFF"; } - return chr $ord; + return pack "U", $ord; } sub import { diff --git a/lib/encoding.pm b/lib/encoding.pm index fd9d19b..2f4b059 100644 --- a/lib/encoding.pm +++ b/lib/encoding.pm @@ -66,9 +66,6 @@ If no encoding can be found, C error will be thrown. The C<\x..> and C<\0...> in regular expressions are not affected by this pragma. They very probably should. -The charnames pragma ("\N{LATIN SMALL SHARP LETTER S}") does not work -with this pragma. - =head1 SEE ALSO L, L diff --git a/lib/encoding.t b/lib/encoding.t index 4dee08e6..923baa7 100644 --- a/lib/encoding.t +++ b/lib/encoding.t @@ -1,4 +1,4 @@ -print "1..9\n"; +print "1..10\n"; use encoding "latin1"; # ignored (overwritten by the next line) use encoding "greek"; # iso 8859-7 (no "latin" alias, surprise...) @@ -43,3 +43,9 @@ print "ok 8\n"; # the first octet of UTF-8 encoded 0x3af print "not " unless unpack("C", chr(0xdf)) == 0xce; print "ok 9\n"; + +# charnames must still work +use charnames ':full'; +print "not " unless ord("\N{LATIN SMALL LETTER SHARP S}") == 0xdf; +print "ok 10\n"; +