From 9e5bbba0de25c01ae9355c7a97e237602a37e9f3 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 5 May 2010 12:16:48 -0600 Subject: perlunifaq, uniintro: fix for 80 col display --- pod/perlunifaq.pod | 6 +++--- pod/perluniintro.pod | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'pod') diff --git a/pod/perlunifaq.pod b/pod/perlunifaq.pod index ab42ff194a..8d507709e7 100644 --- a/pod/perlunifaq.pod +++ b/pod/perlunifaq.pod @@ -84,12 +84,12 @@ or encode anymore, on things that use the layered handle. You can provide this layer when Cing the file: - open my $fh, '>:encoding(UTF-8)', $filename; # auto encoding on write - open my $fh, '<:encoding(UTF-8)', $filename; # auto decoding on read + open my $fh, '>:encoding(UTF-8)', $filename; # auto encoding on write + open my $fh, '<:encoding(UTF-8)', $filename; # auto decoding on read Or if you already have an open filehandle: - binmode $fh, ':encoding(UTF-8)'; + binmode $fh, ':encoding(UTF-8)'; Some database drivers for DBI can also automatically encode and decode, but that is sometimes limited to the UTF-8 encoding. diff --git a/pod/perluniintro.pod b/pod/perluniintro.pod index bee286f5ea..54ce2f0a1c 100644 --- a/pod/perluniintro.pod +++ b/pod/perluniintro.pod @@ -344,7 +344,8 @@ layer when opening files The I/O layers can also be specified more flexibly with the C pragma. See L, or look at the following example. - use open ':encoding(utf8)'; # input/output default encoding will be UTF-8 + use open ':encoding(utf8)'; # input/output default encoding will be + # UTF-8 open X, ">file"; print X chr(0x100), "\n"; close X; @@ -355,7 +356,8 @@ the C pragma. See L, or look at the following example. With the C pragma you can use the C<:locale> layer BEGIN { $ENV{LC_ALL} = $ENV{LANG} = 'ru_RU.KOI8-R' } - # the :locale will probe the locale environment variables like LC_ALL + # the :locale will probe the locale environment variables like + # LC_ALL use open OUT => ':locale'; # russki parusski open(O, ">koi8"); print O chr(0x430); # Unicode CYRILLIC SMALL LETTER A = KOI8-R 0xc1 @@ -432,13 +434,13 @@ its argument so that Unicode characters with code points greater than 255 are displayed as C<\x{...}>, control characters (like C<\n>) are displayed as C<\x..>, and the rest of the characters as themselves: - sub nice_string { - join("", - map { $_ > 255 ? # if wide character... - sprintf("\\x{%04X}", $_) : # \x{...} - chr($_) =~ /[[:cntrl:]]/ ? # else if control character ... - sprintf("\\x%02X", $_) : # \x.. - quotemeta(chr($_)) # else quoted or as themselves + sub nice_string { + join("", + map { $_ > 255 ? # if wide character... + sprintf("\\x{%04X}", $_) : # \x{...} + chr($_) =~ /[[:cntrl:]]/ ? # else if control character ... + sprintf("\\x%02X", $_) : # \x.. + quotemeta(chr($_)) # else quoted or as themselves } unpack("W*", $_[0])); # unpack Unicode characters } @@ -731,11 +733,11 @@ or: You can find the bytes that make up a UTF-8 sequence with - @bytes = unpack("C*", $Unicode_string) + @bytes = unpack("C*", $Unicode_string) and you can create well-formed Unicode with - $Unicode_string = pack("U*", 0xff, ...) + $Unicode_string = pack("U*", 0xff, ...) =item * -- cgit v1.2.1