This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta: Fix typo
[perl5.git] / pod / perlunicook.pod
index 4196347..eb395f7 100644 (file)
@@ -26,14 +26,15 @@ to work correctly, with the C<#!> adjusted to work on your system:
  use strict;    # quote strings, declare variables
  use warnings;  # on by default
  use warnings  qw(FATAL utf8);    # fatalize encoding glitches
- use open      qw(:std :utf8);    # undeclared streams in UTF-8
+ use open      qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
  use charnames qw(:full :short);  # unneeded in v5.16
 
 This I<does> make even Unix programmers C<binmode> your binary streams,
 or open them with C<:raw>, but that's the only way to get at them
 portably anyway.
 
-B<WARNING>: C<use autoload> and C<use open> do not get along with each other.
+B<WARNING>: C<use autodie> (pre 2.26) and C<use open> do not get along with each
+other.
 
 =head2 ℞ 1: Generic Unicode-savvy filter
 
@@ -50,7 +51,7 @@ Always decompose on the way in, then recompose on the way out.
 
 =head2 ℞ 2: Fine-tuning Unicode warnings
 
-As of v5.14, Perl distinguishes three sublasses of UTF‑8 warnings.
+As of v5.14, Perl distinguishes three subclasses of UTF‑8 warnings.
 
  use v5.14;                  # subwarnings unavailable any earlier
  no warnings "nonchar";      # the 66 forbidden non-characters
@@ -185,7 +186,7 @@ know how to understand its output.
  # cpan -i Unicode::Unihan
  use Unicode::Unihan;
  my $str = "東京";
- my $unhan = new Unicode::Unihan;
+ my $unhan = Unicode::Unihan->new;
  for my $lang (qw(Mandarin Cantonese Korean JapaneseOn JapaneseKun)) {
      printf "CJK $str in %-12s is ", $lang;
      say $unhan->$lang($str);
@@ -204,7 +205,7 @@ use the specific module:
 
  # cpan -i Lingua::JA::Romanize::Japanese
  use Lingua::JA::Romanize::Japanese;
- my $k2r = new Lingua::JA::Romanize::Japanese;
+ my $k2r = Lingua::JA::Romanize::Japanese->new;
  my $str = "東京";
  say "Japanese for $str is ", $k2r->chars($str);
 
@@ -233,8 +234,8 @@ C<binmode> as described later below.
  or
      $ export PERL_UNICODE=A
  or
-    use Encode qw(decode_utf8);
-    @ARGV = map { decode_utf8($_, 1) } @ARGV;
+    use Encode qw(decode);
+    @ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
 
 =head2 ℞ 14: Decode program arguments as locale encoding
 
@@ -254,9 +255,9 @@ call C<binmode> explicitly:
  or
      $ export PERL_UNICODE=S
  or
-     use open qw(:std :utf8);
+     use open qw(:std :encoding(UTF-8));
  or
-     binmode(STDIN,  ":utf8");
+     binmode(STDIN,  ":encoding(UTF-8)");
      binmode(STDOUT, ":utf8");
      binmode(STDERR, ":utf8");
 
@@ -273,13 +274,13 @@ call C<binmode> explicitly:
 
 =head2 ℞ 17: Make file I/O default to utf8
 
-Files opened without an encoding arugment will be in UTF-8:
+Files opened without an encoding argument will be in UTF-8:
 
      $ perl -CD ...
  or
      $ export PERL_UNICODE=D
  or
-     use open qw(:utf8);
+     use open qw(:encoding(UTF-8));
 
 =head2 ℞ 18: Make all I/O and args default to utf8
 
@@ -287,9 +288,9 @@ Files opened without an encoding arugment will be in UTF-8:
  or
      $ export PERL_UNICODE=SDA
  or
-     use open qw(:std :utf8);
-     use Encode qw(decode_utf8);
-     @ARGV = map { decode_utf8($_, 1) } @ARGV;
+     use open qw(:std :encoding(UTF-8));
+     use Encode qw(decode);
+     @ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
 
 =head2 ℞ 19: Open file with specific encoding
 
@@ -390,7 +391,7 @@ one codepoint lacking that property.
  \p{Sk}, \p{Ps}, \p{Lt}
  \p{alpha}, \p{upper}, \p{lower}
  \p{Latin}, \p{Greek}
- \p{script=Latin}, \p{script=Greek}
+ \p{script_extensions=Latin}, \p{scx=Greek}
  \p{East_Asian_Width=Wide}, \p{EA=W}
  \p{Line_Break=Hyphen}, \p{LB=HY}
  \p{Numeric_Value=4}, \p{NV=4}
@@ -439,7 +440,7 @@ convert such strings manually.
  use Unicode::UCD qw(num);
  my $str = "got Ⅻ and ४५६७ and ⅞ and here";
  my @nums = ();
- while (/$str =~ (\d+|\N)/g) {  # not just ASCII!
+ while ($str =~ /(\d+|\N)/g) {  # not just ASCII!
     push @nums, num($1);
  }
  say "@nums";   #     12      4567      0.875
@@ -533,7 +534,7 @@ use the UCA for sorting text.
  my @list = $col->sort(@old_list);
 
 See the I<ucsort> program from the L<Unicode::Tussle> CPAN module
-for a conveninent command-line interface to this module.
+for a convenient command-line interface to this module.
 
 =head2 ℞ 36: Case- I<and> accent-insensitive Unicode sort
 
@@ -612,7 +613,7 @@ Break up text into lines according to Unicode rules.
  use charnames qw(:full);
 
  my $para = "This is a super\N{HYPHEN}long string. " x 20;
- my $fmt = new Unicode::LineBreak;
+ my $fmt = Unicode::LineBreak->new;
  print $fmt->break($para), "\n";
 
 =head2 ℞ 42: Unicode text in DBM hashes, the tedious way
@@ -637,7 +638,7 @@ won’t fit into a byte.  Here’s how to manually manage the translation:
     # assume $uni_key holds a normal Perl string (abstract Unicode)
     my $enc_key   = encode("UTF-8", $uni_key, 1);
     my $enc_value = $dbhash{$enc_key};
-    my $uni_value = decode("UTF-8", $enc_key, 1);
+    my $uni_value = decode("UTF-8", $enc_value, 1);
 
 =head2 ℞ 43: Unicode text in DBM hashes, the easy way
 
@@ -700,7 +701,7 @@ Here's that program; tested on v5.14.
  use strict;
  use warnings;
  use warnings  qw(FATAL utf8);    # fatalize encoding faults
- use open      qw(:std :utf8);    # undeclared streams in UTF-8
+ use open      qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
  use charnames qw(:full :short);  # unneeded in v5.16
 
  # std modules
@@ -733,7 +734,8 @@ Here's that program; tested on v5.14.
      "寿司"              => 9.99, # sushi, Japanese
      "おもち"            => 2.65, # omochi, rice cakes, Japanese
      "crème brûlée"      => 2.00, # crema catalana
-     "fideuà"            => 4.20, # more noodles, Valencian (Catalan=fideuada)
+     "fideuà"            => 4.20, # more noodles, Valencian
+                                  # (Catalan=fideuada)
      "pâté"              => 4.15, # gooseliver paste, French
      "お好み焼き"        => 8.00, # okonomiyaki, Japanese
  );
@@ -743,7 +745,7 @@ Here's that program; tested on v5.14.
  # So the Asian stuff comes out in an order that someone
  # who reads those scripts won't freak out over; the
  # CJK stuff will be in JIS X 0208 order that way.
- my $coll  = new Unicode::Collate::Locale locale => "ja";
+ my $coll  = Unicode::Collate::Locale->new(locale => "ja");
 
  for my $item ($coll->sort(keys %price)) {
      print pad(entitle($item), $width, ".");
@@ -814,8 +816,6 @@ Finally, see the published Unicode Standard (page numbers are from version
 §4.2  Case, pages 120–122;
 Case Mappings, page 166–172, especially Caseless Matching starting on page 170.
 
-=item
-
 =item UAX #44: Unicode Character Database
 
 =item UTS #18: Unicode Regular Expressions
@@ -852,7 +852,6 @@ spindle, and mutilate any of the examples in this manpage however you please
 for inclusion into your own programs without any encumbrance whatsoever.
 Acknowledgement via code comment is polite but not required.
 
-=head1 REVISON HISTORY
+=head1 REVISION HISTORY
 
 v1.0.0 – first public release, 2012-02-27
-