This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Work-around Uni 6.0 issues with 'BELL'
authorKarl Williamson <public@khwilliamson.com>
Wed, 17 Nov 2010 01:29:07 +0000 (18:29 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 18 Nov 2010 20:58:24 +0000 (12:58 -0800)
Unicode version 6.0 has co-opted the name BELL for a different character
than traditionally used in Perl.  This patch works around that by adding
ALERT as a synonym for BELL, and causing a deprecated warning for uses
of the old name.

The new Unicode character will be nameless in Perl 5.14, unless I can
(unlikely) get Unicode to grant a synonym that they will support.

lib/charnames.pm
lib/charnames.t
lib/unicore/mktables
pod/perldelta.pod

index 677edfc..750b1cf 100644 (file)
@@ -2,7 +2,7 @@ package charnames;
 use strict;
 use warnings;
 use File::Spec;
-our $VERSION = '1.16';
+our $VERSION = '1.17';
 
 use bytes ();          # for $bytes::hint_bits
 
@@ -35,7 +35,7 @@ my %system_aliases = (
     'EOT'           => pack("U", 0x04), # END OF TRANSMISSION
     'ENQ'           => pack("U", 0x05), # ENQUIRY
     'ACK'           => pack("U", 0x06), # ACKNOWLEDGE
-    'BEL'           => pack("U", 0x07), # BELL
+    'BEL'           => pack("U", 0x07), # ALERT; formerly BELL
     'BS'            => pack("U", 0x08), # BACKSPACE
     'HT'            => pack("U", 0x09), # HORIZONTAL TABULATION
     'LF'            => pack("U", 0x0A), # LINE FEED (LF)
@@ -401,6 +401,9 @@ my %deprecated_aliases = (
     'PARTIAL LINE UP'         => pack("U", 0x8C), # PARTIAL LINE BACKWARD
     'VERTICAL TABULATION SET' => pack("U", 0x8A), # LINE TABULATION SET
     'REVERSE INDEX'           => pack("U", 0x8D), # REVERSE LINE FEED
+
+    # Unicode 6.0 co-opted this for U+1F514, so deprecate it for now.
+    'BELL'                    => pack("U", 0x07),
 );
 
 
index 46f206a..f44c805 100644 (file)
@@ -249,6 +249,11 @@ is("\N{BOM}", chr(0xFEFF));
 
     ok(grep { /"HORIZONTAL TABULATION" is deprecated.*CHARACTER TABULATION/ } @WARN);
 
+    # XXX These tests should be changed for 5.16, when we convert BELL to the
+    # Unicode version.
+    is("\N{BELL}", "\a");
+    ok((grep{ /"BELL" is deprecated.*ALERT/ } @WARN), 'BELL is deprecated');
+
     no warnings 'deprecated';
 
     is("\N{VERTICAL TABULATION}", "\013");
@@ -914,6 +919,12 @@ is("\N{U+1D0C5}", "\N{BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS}");
         # marked <control>
         $name = $u1name if $name eq "<control>";
 
+        $name = 'ALERT' if $decimal == 7;
+
+        # XXX This test should be changed for 5.16 when we convert to use
+        # Unicode's BELL
+        $name = "" if $decimal == 0x1F514;
+
         # Some don't have names, leave those array elements undefined
         next unless $name;
 
index f584882..6c13acd 100644 (file)
@@ -10145,6 +10145,28 @@ END
         }
         return;
     }
+
+    sub filter_v6_ucd {
+
+        # Unicode 6.0 co-opted the name BELL for U+1F514, so change the input
+        # to pretend that U+0007 is ALERT instead, and for Perl 5.14, don't
+        # allow the BELL name for U+1F514, so that the old usage can be
+        # deprecated for one cycle.
+
+        return if $_ !~ /^(?:0007|1F514);/;
+
+        my ($code_point, @fields) = split /\s*;\s*/, $_, -1;
+        if ($code_point eq '0007') {
+            $fields[$UNICODE_1_NAME] = "ALERT";
+        }
+        elsif ($^V lt v5.15.0) { # For 5.16 will convert to use Unicode's name
+            $fields[$CHARNAME] = "";
+        }
+
+        $_ = join ';', $code_point, @fields;
+
+        return;
+    }
 } # End closure for UnicodeData
 
 sub process_GCB_test {
@@ -14072,7 +14094,12 @@ my @input_file_objects = (
                                             ? \&filter_v1_ucd
                                             : ($v_version eq v2.1.5)
                                                 ? \&filter_v2_1_5_ucd
-                                                : undef),
+
+                                                # And for 5.14 Perls with 6.0,
+                                                # have to also make changes
+                                                : ($v_version ge v6.0.0)
+                                                    ? \&filter_v6_ucd
+                                                    : undef),
 
                                             # And the main filter
                                             \&filter_UnicodeData_line,
index f627dbb..05cb929 100644 (file)
@@ -140,14 +140,29 @@ introspection of the current phase of the perl interpreter. It's explained in
 detail in L<perlvar/"${^GLOBAL_PHASE}"> and
 L<perlmod/"BEGIN, UNITCHECK, CHECK, INIT and END">.
 
-=head2 Unicode Version 6.0 is now supported.
+=head2 Unicode Version 6.0 is now supported (mostly)
 
-Perl comes with the Unicode 6.0 data base.
+Perl comes with the Unicode 6.0 data base, with one exception noted
+below.
 See L<http://unicode.org/versions/Unicode6.0.0> for details on the new
 release.  Perl does not support any Unicode provisional properties,
 including the new ones for this release, but their database files are
 packaged with Perl.
 
+Unicode 6.0 has chosen to use the name C<BELL> for the character at U+1F514,
+which is a symbol that looks like a bell, and used in Japanese cell
+phones.  This conflicts with the long-standing Perl usage of having
+C<BELL> mean the ASCII C<BEL> character, U+0007.  In Perl 5.14,
+C<\N{BELL}> will continue to mean U+0007, but its use will generate a
+deprecated warning message, unless such warnings are turned off.  The
+new name for U+0007 in Perl will be C<ALERT>, which corresponds nicely
+with the existing shorthand sequence for it, C<"\a">.  C<\N{BEL}> will
+mean U+0007, with no warning given.  The character at U+1F514 will not
+have a name in 5.14, but can be referred to by C<\N{U+1F514}>.  The plan
+is that in Perl 5.16, C<\N{BELL}> will refer to U+1F514, and so all code
+that uses C<\N{BELL}> should convert by then to using C<\N{ALERT}>,
+C<\N{BEL}>, or C<"\a"> instead.
+
 =head1 Security
 
 XXX Any security-related notices go here.  In particular, any security
@@ -229,6 +244,12 @@ listed as an updated module in the L</Modules and Pragmata> section.
 
 [ List each deprecation as a =head2 entry ]
 
+=head2 C<\N{BELL}> is deprecated
+
+This is because Unicode is using that name for a different character.
+See L</Unicode Version 6.0 is now supported (mostly)> for more
+explanation.
+
 =head1 Performance Enhancements
 
 XXX Changes which enhance performance without changing behaviour go here. There