This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make "\N{...}" enable utf8-ness correctly
authorGurusamy Sarathy <gsar@cpan.org>
Sat, 18 Mar 2000 04:21:43 +0000 (04:21 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sat, 18 Mar 2000 04:21:43 +0000 (04:21 +0000)
p4raw-id: //depot/perl@5797

t/lib/charnames.t
toke.c

index f4d9577..a6fe47f 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 }
 
 $| = 1;
-print "1..5\n";
+print "1..10\n";
 
 use charnames ':full';
 
@@ -44,7 +44,6 @@ $encoded_alpha = "\316\261";
 $encoded_bet = "\327\221";
 {
   use charnames ':full';
-  use utf8;
 
   print "not " unless "\N{CYRILLIC SMALL LETTER BE}" eq $encoded_be;
   print "ok 4\n";
@@ -55,3 +54,17 @@ $encoded_bet = "\327\221";
     eq "$encoded_be,$encoded_alpha,$encoded_bet";
   print "ok 5\n";
 }
+
+{
+    use charnames ':full';
+    print "not " unless "\x{263a}" eq "\N{WHITE SMILING FACE}";
+    print "ok 6\n";
+    print "not " unless length("\x{263a}") == 1;
+    print "ok 7\n";
+    print "not " unless length("\N{WHITE SMILING FACE}") == 1;
+    print "ok 8\n";
+    print "not " unless sprintf("%vx", "\x{263a}") eq "263a";
+    print "ok 9\n";
+    print "not " unless sprintf("%vx", "\N{WHITE SMILING FACE}") eq "263a";
+    print "ok 10\n";
+}
diff --git a/toke.c b/toke.c
index dcb4454..2d96802 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1479,6 +1479,8 @@ S_scan_const(pTHX_ char *start)
                    res = new_constant( Nullch, 0, "charnames", 
                                        res, Nullsv, "\\N{...}" );
                    str = SvPV(res,len);
+                   if (len > 1)
+                       has_utf = TRUE;
                    if (len > e - s + 4) {
                        char *odest = SvPVX(sv);