summaryrefslogtreecommitdiff
path: root/lib/encoding.pm
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-07 22:37:51 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-07 22:37:51 +0000
commit799ef3cbf1e54d039c2681bb415c66a8acfbc6cd (patch)
treee300409ec36e330b6f2b305d2e662e2ebfa4b58f /lib/encoding.pm
parentcf48d248eb62e81239204ca4ca6b33029875e0bd (diff)
downloadperl-799ef3cbf1e54d039c2681bb415c66a8acfbc6cd.tar.gz
As suggested by Anton Tagunov, eq and cmp now obey the
encoding pragma (by remapping their byte argument if the other argument is in Unicode). Also fix a bug found by Anton where ord undef under the encoding pragma would barf. ([ID 20020307.009] A null pointer dereference with 'use encoding') Finally, use the nicer form of sv_recode_to_utf8. p4raw-id: //depot/perl@15085
Diffstat (limited to 'lib/encoding.pm')
-rw-r--r--lib/encoding.pm9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/encoding.pm b/lib/encoding.pm
index 1504a92639..44fc2fdc00 100644
--- a/lib/encoding.pm
+++ b/lib/encoding.pm
@@ -52,10 +52,15 @@ encoding - pragma to control the conversion of legacy data into Unicode
print "tera\n" if ord(pack("C", 0xdf)) == 0x3af;
- # but pack/unpack are not affected, in case you still
+ # ... as are eq and cmp ...
+
+ print "peta\n" if "\x{3af}" eq pack("C", 0xdf);
+ print "exa\n" if "\x{3af}" cmp pack("C", 0xdf) == 0;
+
+ # ... but pack/unpack C are not affected, in case you still
# want back to your native encoding
- print "peta\n" if unpack("C", (pack("C", 0xdf))) == 0xdf;
+ print "zetta\n" if unpack("C", (pack("C", 0xdf))) == 0xdf;
=head1 DESCRIPTION