perlunicook > 5.24.1 との差分

perlunicook 5.24.1 と 5.38.0 の差分

11
22=encoding utf8
33
44=head1 NAME
55
66=begin original
77
88perlunicook - cookbookish examples of handling Unicode in Perl
99
1010=end original
1111
1212perlunicook - Perl で Unicode を扱うためのクックブック風の例
1313
1414=head1 DESCRIPTION
1515
1616=begin original
1717
1818This manpage contains short recipes demonstrating how to handle common Unicode
1919operations in Perl, plus one complete program at the end. Any undeclared
2020variables in individual recipes are assumed to have a previous appropriate
2121value in them.
2222
2323=end original
2424
2525この man ページには、Perl で一般的な Unicode 操作を扱う方法を説明する
2626短いレシピと、最後に一つの完全なプログラムが含まれています。
2727個々のレシピ内の宣言されていない変数は、それ以前に適切な値が
2828設定されていることを仮定しています。
2929
3030=head1 EXAMPLES
3131
3232=head2 ℞ 0: Standard preamble
3333
3434(℞ 0: 標準の前提)
3535
3636=begin original
3737
3838Unless otherwise notes, all examples below require this standard preamble
3939to work correctly, with the C<#!> adjusted to work on your system:
4040
4141=end original
4242
4343特に注記がない限り、以下のすべての例では、この標準の前提が正しく動作し、
4444C<#!> がシステム上で動作するように調整されている必要があります。
4545
4646 #!/usr/bin/env perl
4747
4848=begin original
4949
50 use v5.36; # or later to get "unicode_strings" feature,
51 # plus strict, warnings
5052 use utf8; # so literals and identifiers can be in UTF-8
51 use v5.12; # or later to get "unicode_strings" feature
52 use strict; # quote strings, declare variables
53 use warnings; # on by default
5453 use warnings qw(FATAL utf8); # fatalize encoding glitches
55 use open qw(:std :utf8); # undeclared streams in UTF-8
54 use open qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
5655 use charnames qw(:full :short); # unneeded in v5.16
5756
5857=end original
5958
59 use v5.36; # またはそれ以降; "unicode_strings" 機能を有効に
60 # 加えて strict, warnings
6061 use utf8; # 従ってリテラルと識別子で UTF-8 を使える
61 use v5.12; # またはそれ以降; "unicode_strings" 機能を有効に
62 use strict; # 文字列をクォート、変数を宣言
63 use warnings; # デフォルトでオン
6462 use warnings qw(FATAL utf8); # エンコーディングエラーを致命的エラーに
65 use open qw(:std :utf8); # 未宣言ストリームを UTF-8 に
63 use open qw(:std :encoding(UTF-8)); # 未宣言ストリームを UTF-8 に
6664 use charnames qw(:full :short); # v5.16 では不要
6765
6866=begin original
6967
7068This I<does> make even Unix programmers C<binmode> your binary streams,
7169or open them with C<:raw>, but that's the only way to get at them
7270portably anyway.
7371
7472=end original
7573
7674これは Unix プログラマでさえバイナリストリームを C<binmode> したり、
7775C<:raw> で開いたり I<しています> が、それがとにかくこれらを
7876移植性のあるものにする唯一の方法です。
7977
8078=begin original
8179
8280B<WARNING>: C<use autodie> (pre 2.26) and C<use open> do not get along with each
8381other.
8482
8583=end original
8684
8785B<警告>: C<use autodie>(2.26 より前)と C<use open> は同時に使えません。
8886
8987=head2 ℞ 1: Generic Unicode-savvy filter
9088
9189(℞ 1: 一般的な Unicode が使えるフィルタ)
9290
9391=begin original
9492
9593Always decompose on the way in, then recompose on the way out.
9694
9795=end original
9896
9997常に、入り口で分解し、出口で再合成します。
10098
10199 use Unicode::Normalize;
102100
103101 while (<>) {
104102 $_ = NFD($_); # decompose + reorder canonically
105103 ...
106104 } continue {
107105 print NFC($_); # recompose (where possible) + reorder canonically
108106 }
109107
110108=head2 ℞ 2: Fine-tuning Unicode warnings
111109
112110(℞ 2: Unicode 警告の微調整)
113111
114112=begin original
115113
116114As of v5.14, Perl distinguishes three subclasses of UTF‑8 warnings.
117115
118116=end original
119117
120118v5.14 から、Perl は UTF-8 警告の三つのサブクラスを区別しています。
121119
122120 use v5.14; # subwarnings unavailable any earlier
123121 no warnings "nonchar"; # the 66 forbidden non-characters
124122 no warnings "surrogate"; # UTF-16/CESU-8 nonsense
125123 no warnings "non_unicode"; # for codepoints over 0x10_FFFF
126124
127125=head2 ℞ 3: Declare source in utf8 for identifiers and literals
128126
129127(℞ 3: 識別子とリテラルのためにソースが utf8 であると宣言する)
130128
131129=begin original
132130
133131Without the all-critical C<use utf8> declaration, putting UTF‑8 in your
134132literals and identifiers won’t work right. If you used the standard
135133preamble just given above, this already happened. If you did, you can
136134do things like this:
137135
138136=end original
139137
140138最も重要な C<use utf8> 宣言なしの場合、リテラルと識別子に
141139UTF-8 を入れると正しく動作しません。
142140前述した標準の前提を使った場合、これは既に含まれています。
143141その場合、以下のようなことができます:
144142
145143 use utf8;
146144
147145 my $measure = "Ångström";
148146 my @μsoft = qw( cp852 cp1251 cp1252 );
149147 my @ὑπέρμεγας = qw( ὑπέρ μεγας );
150148 my @鯉 = qw( koi8-f koi8-u koi8-r );
151149 my $motto = "👪 💗 🐪"; # FAMILY, GROWING HEART, DROMEDARY CAMEL
152150
153151=begin original
154152
155153If you forget C<use utf8>, high bytes will be misunderstood as
156154separate characters, and nothing will work right.
157155
158156=end original
159157
160158C<use utf8> を忘れると、上位バイトは別々の文字として誤解され、
161159何も正しく動作しません。
162160
163161=head2 ℞ 4: Characters and their numbers
164162
165163(℞ 4: 文字とその番号)
166164
167165=begin original
168166
169167The C<ord> and C<chr> functions work transparently on all codepoints,
170168not just on ASCII alone — nor in fact, not even just on Unicode alone.
171169
172170=end original
173171
174172C<ord> 関数と C<chr> 関数は、すべての符号位置で透過的に動作します;
175173ASCII だけではなく、実際には Unicode だけでもありません。
176174
177175 # ASCII characters
178176 ord("A")
179177 chr(65)
180178
181179 # characters from the Basic Multilingual Plane
182180 ord("Σ")
183181 chr(0x3A3)
184182
185183 # beyond the BMP
186184 ord("𝑛") # MATHEMATICAL ITALIC SMALL N
187185 chr(0x1D45B)
188186
189187 # beyond Unicode! (up to MAXINT)
190188 ord("\x{20_0000}")
191189 chr(0x20_0000)
192190
193191=head2 ℞ 5: Unicode literals by character number
194192
195193(℞ 5: 文字番号による Unicode リテラル)
196194
197195=begin original
198196
199197In an interpolated literal, whether a double-quoted string or a
200198regex, you may specify a character by its number using the
201199C<\x{I<HHHHHH>}> escape.
202200
203201=end original
204202
205203展開リテラルでは、ダブルクォートで囲まれた文字列か正規表現かにかかわらず、
206204C<\x{I<HHHHHH>}> エスケープを使用して番号で文字を指定できます。
207205
208206 String: "\x{3a3}"
209207 Regex: /\x{3a3}/
210208
211209 String: "\x{1d45b}"
212210 Regex: /\x{1d45b}/
213211
214212 # even non-BMP ranges in regex work fine
215213 /[\x{1D434}-\x{1D467}]/
216214
217215=head2 ℞ 6: Get character name by number
218216
219217(℞ 6: 番号で文字名を取得する)
220218
221219 use charnames ();
222220 my $name = charnames::viacode(0x03A3);
223221
224222=head2 ℞ 7: Get character number by name
225223
226224(℞ 7: 名前で文字番号を取得する)
227225
228226 use charnames ();
229227 my $number = charnames::vianame("GREEK CAPITAL LETTER SIGMA");
230228
231229=head2 ℞ 8: Unicode named characters
232230
233231(℞ 8: Unicode 名による文字)
234232
235233=begin original
236234
237235Use the C<< \N{I<charname>} >> notation to get the character
238236by that name for use in interpolated literals (double-quoted
239237strings and regexes). In v5.16, there is an implicit
240238
241239=end original
242240
243241展開リテラル(ダブルクォートで囲まれた文字列と正規表現)で用いる、
244242名前で文字を得るために C<<\N{I<charname>}>> 表記を使います。
245243v5.16 では、これは暗黙に指定されます:
246244
247245 use charnames qw(:full :short);
248246
249247=begin original
250248
251249But prior to v5.16, you must be explicit about which set of charnames you
252250want. The C<:full> names are the official Unicode character name, alias, or
253251sequence, which all share a namespace.
254252
255253=end original
256254
257255しかし、v5.16 より前のバージョンでは、どの charnames の集合を使用するかを
258256明示的に指定しなければなりません。
259257C<:full> の名前は、Unicode の正式な文字名、別名、または
260258並びであり、すべて名前空間を共有します。
261259
262260 use charnames qw(:full :short latin greek);
263261
264262 "\N{MATHEMATICAL ITALIC SMALL N}" # :full
265263 "\N{GREEK CAPITAL LETTER SIGMA}" # :full
266264
267265=begin original
268266
269267Anything else is a Perl-specific convenience abbreviation. Specify one or
270268more scripts by names if you want short names that are script-specific.
271269
272270=end original
273271
274272それ以外は、Perl 固有の便利な省略形です。
275273用字固有の短い名前が必要な場合は、一つ以上の用字を名前で指定します。
276274
277275 "\N{Greek:Sigma}" # :short
278276 "\N{ae}" # latin
279277 "\N{epsilon}" # greek
280278
281279=begin original
282280
283281The v5.16 release also supports a C<:loose> import for loose matching of
284282character names, which works just like loose matching of property names:
285283that is, it disregards case, whitespace, and underscores:
286284
287285=end original
288286
289287v5.16 リリースでは、文字名の緩やかなマッチングのための
290288C<:loose> インポートにも対応しています;
291289これは特性名の緩やかなマッチングと同じように機能します:
292290つまり、大文字小文字、空白、下線は無視されます:
293291
294292 "\N{euro sign}" # :loose (from v5.16)
295293
294=begin original
295
296Starting in v5.32, you can also use
297
298=end original
299
300v5.32 から、次のものを使って:
301
302 qr/\p{name=euro sign}/
303
304=begin original
305
306to get official Unicode named characters in regular expressions. Loose
307matching is always done for these.
308
309=end original
310
311公式な正規表現での Unicode の名前の文字を得られます。
312緩いマッチングは常にこれらで行われます。
313
296314=head2 ℞ 9: Unicode named sequences
297315
298316(℞ 9: Unicode 名による並び)
299317
300318=begin original
301319
302320These look just like character names but return multiple codepoints.
303321Notice the C<%vx> vector-print functionality in C<printf>.
304322
305323=end original
306324
307325これらは文字名のように見えますが、複数の符号位置を返します。
308326C<printf> の C<%vx> ベクトル表示機能に注目してください。
309327
310328 use charnames qw(:full);
311329 my $seq = "\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}";
312330 printf "U+%v04X\n", $seq;
313331 U+0100.0300
314332
315333=head2 ℞ 10: Custom named characters
316334
317335(℞ 10: カスタム名による文字)
318336
319337=begin original
320338
321339Use C<:alias> to give your own lexically scoped nicknames to existing
322340characters, or even to give unnamed private-use characters useful names.
323341
324342=end original
325343
326344C<:alias> を使用して、既存の文字に対してレキシカルスコープの
327345独自のニックネームを付けたり、無名の私用文字に有用な名前を
328346付けることができます。
329347
330348 use charnames ":full", ":alias" => {
331349 ecute => "LATIN SMALL LETTER E WITH ACUTE",
332350 "APPLE LOGO" => 0xF8FF, # private use character
333351 };
334352
335353 "\N{ecute}"
336354 "\N{APPLE LOGO}"
337355
338356=head2 ℞ 11: Names of CJK codepoints
339357
340358(℞ 11: CJK 符号位置の名前)
341359
342360=begin original
343361
344362Sinograms like “東京” come back with character names of
345363C<CJK UNIFIED IDEOGRAPH-6771> and C<CJK UNIFIED IDEOGRAPH-4EAC>,
346364because their “names” vary. The CPAN C<Unicode::Unihan> module
347365has a large database for decoding these (and a whole lot more), provided you
348366know how to understand its output.
349367
350368=end original
351369
352370「東京」のような中国漢字は、「名前」が異なるため、
353371C<CJK UNIFIED IDEOGRAPH-6771> と
354372C<CJK UNIFIED IDEOGRAPH-4EAC> という文字名で戻ってきます。
355373CPAN の C<Unicode::Unihan> モジュールは、その出力を理解する方法を
356374知っていれば、これら(およびさらに多くの)文字をデコードするための
357375大規模なデータベースを持ちます。
358376
359377 # cpan -i Unicode::Unihan
360378 use Unicode::Unihan;
361379 my $str = "東京";
362380 my $unhan = Unicode::Unihan->new;
363381 for my $lang (qw(Mandarin Cantonese Korean JapaneseOn JapaneseKun)) {
364382 printf "CJK $str in %-12s is ", $lang;
365383 say $unhan->$lang($str);
366384 }
367385
368386=begin original
369387
370388prints:
371389
372390=end original
373391
374392これは次のものを表示します:
375393
376394 CJK 東京 in Mandarin is DONG1JING1
377395 CJK 東京 in Cantonese is dung1ging1
378396 CJK 東京 in Korean is TONGKYENG
379397 CJK 東京 in JapaneseOn is TOUKYOU KEI KIN
380398 CJK 東京 in JapaneseKun is HIGASHI AZUMAMIYAKO
381399
382400=begin original
383401
384402If you have a specific romanization scheme in mind,
385403use the specific module:
386404
387405=end original
388406
389407特定のローマ字化スキームを考えている場合は、特定のモジュールを使います:
390408
391409 # cpan -i Lingua::JA::Romanize::Japanese
392410 use Lingua::JA::Romanize::Japanese;
393411 my $k2r = Lingua::JA::Romanize::Japanese->new;
394412 my $str = "東京";
395413 say "Japanese for $str is ", $k2r->chars($str);
396414
397415=begin original
398416
399417prints
400418
401419=end original
402420
403421これは次のものを表示します:
404422
405423 Japanese for 東京 is toukyou
406424
407425=head2 ℞ 12: Explicit encode/decode
408426
409427(℞ 12: 明示的なエンコード/デコード)
410428
411429=begin original
412430
413431On rare occasion, such as a database read, you may be
414432given encoded text you need to decode.
415433
416434=end original
417435
418436まれに、データベースの読み取りなど、デコードする必要がある
419437エンコードされたテキストを受け取ることがあります。
420438
421439 use Encode qw(encode decode);
422440
423441 my $chars = decode("shiftjis", $bytes, 1);
424442 # OR
425443 my $bytes = encode("MIME-Header-ISO_2022_JP", $chars, 1);
426444
427445=begin original
428446
429447For streams all in the same encoding, don't use encode/decode; instead
430448set the file encoding when you open the file or immediately after with
431449C<binmode> as described later below.
432450
433451=end original
434452
435453同じエンコーディングのストリームに対しては、encode/decode を
436454使わないでください;
437455代わりに、後述するように、ファイルを開くとき、またはその直後に
438456C<binmode> でファイルエンコーディングを設定してください。
439457
440458=head2 ℞ 13: Decode program arguments as utf8
441459
442460(℞ 13: プログラム引数を utf8 としてデコードする)
443461
444462 $ perl -CA ...
445463 or
446464 $ export PERL_UNICODE=A
447465 or
448 use Encode qw(decode_utf8);
466 use Encode qw(decode);
449 @ARGV = map { decode_utf8($_, 1) } @ARGV;
467 @ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
450468
451469=head2 ℞ 14: Decode program arguments as locale encoding
452470
453471(℞ 14: プログラム引数をロケールエンコーディングとしてデコードする)
454472
455473 # cpan -i Encode::Locale
456474 use Encode qw(locale);
457475 use Encode::Locale;
458476
459477 # use "locale" as an arg to encode/decode
460478 @ARGV = map { decode(locale => $_, 1) } @ARGV;
461479
462480=head2 ℞ 15: Declare STD{IN,OUT,ERR} to be utf8
463481
464482(℞ 15: STD{IN,OUT,ERR} を utf8 として宣言する)
465483
466484=begin original
467485
468486Use a command-line option, an environment variable, or else
469487call C<binmode> explicitly:
470488
471489=end original
472490
473491コマンドラインオプションや環境変数を使うか、明示的に
474492C<binmode> を呼び出します。
475493
476494 $ perl -CS ...
477495 or
478496 $ export PERL_UNICODE=S
479497 or
480 use open qw(:std :utf8);
498 use open qw(:std :encoding(UTF-8));
481499 or
482 binmode(STDIN, ":utf8");
500 binmode(STDIN, ":encoding(UTF-8)");
483501 binmode(STDOUT, ":utf8");
484502 binmode(STDERR, ":utf8");
485503
486504=head2 ℞ 16: Declare STD{IN,OUT,ERR} to be in locale encoding
487505
488506(℞ 15: STD{IN,OUT,ERR} をロケールエンコーディングとして宣言する)
489507
490508 # cpan -i Encode::Locale
491509 use Encode;
492510 use Encode::Locale;
493511
494512 # or as a stream for binmode or open
495513 binmode STDIN, ":encoding(console_in)" if -t STDIN;
496514 binmode STDOUT, ":encoding(console_out)" if -t STDOUT;
497515 binmode STDERR, ":encoding(console_out)" if -t STDERR;
498516
499517=head2 ℞ 17: Make file I/O default to utf8
500518
501519(℞ 17: ファイル I/O のデフォルトを utf8 にする)
502520
503521=begin original
504522
505523Files opened without an encoding argument will be in UTF-8:
506524
507525=end original
508526
509527encoding 引数なしで開かれたファイルは UTF-8 になります:
510528
511529 $ perl -CD ...
512530 or
513531 $ export PERL_UNICODE=D
514532 or
515 use open qw(:utf8);
533 use open qw(:encoding(UTF-8));
516534
517535=head2 ℞ 18: Make all I/O and args default to utf8
518536
519537(℞ 18: 全ての I/O と引数のデフォルトを utf8 にする)
520538
521539 $ perl -CSDA ...
522540 or
523541 $ export PERL_UNICODE=SDA
524542 or
525 use open qw(:std :utf8);
543 use open qw(:std :encoding(UTF-8));
526 use Encode qw(decode_utf8);
544 use Encode qw(decode);
527 @ARGV = map { decode_utf8($_, 1) } @ARGV;
545 @ARGV = map { decode('UTF-8', $_, 1) } @ARGV;
528546
529547=head2 ℞ 19: Open file with specific encoding
530548
531549(℞ 19: 特定のエンコーディングでファイルを開く)
532550
533551=begin original
534552
535553Specify stream encoding. This is the normal way
536554to deal with encoded text, not by calling low-level
537555functions.
538556
539557=end original
540558
541559ストリームエンコーディングを指定します。
542560これは、低レベル関数を呼び出すのではなく、エンコードされたテキストを
543561処理する通常の方法です。
544562
545563 # input file
546564 open(my $in_file, "< :encoding(UTF-16)", "wintext");
547565 OR
548566 open(my $in_file, "<", "wintext");
549567 binmode($in_file, ":encoding(UTF-16)");
550568 THEN
551569 my $line = <$in_file>;
552570
553571 # output file
554572 open($out_file, "> :encoding(cp1252)", "wintext");
555573 OR
556574 open(my $out_file, ">", "wintext");
557575 binmode($out_file, ":encoding(cp1252)");
558576 THEN
559577 print $out_file "some text\n";
560578
561579=begin original
562580
563581More layers than just the encoding can be specified here. For example,
564582the incantation C<":raw :encoding(UTF-16LE) :crlf"> includes implicit
565583CRLF handling.
566584
567585=end original
568586
569587ここで指定できるのは、エンコーディングだけではありません。
570588例えば、呪文 C<":raw :encoding(UTF-16LE) :crlf"> には
571589暗黙的な CRLF 処理が含まれています。
572590
573591=head2 ℞ 20: Unicode casing
574592
575593(℞ 20: Unicode の大文字小文字)
576594
577595=begin original
578596
579597Unicode casing is very different from ASCII casing.
580598
581599=end original
582600
583601Unicode の大文字小文字は ASCII の大文字小文字とは大きく異なります。
584602
585603 uc("henry ⅷ") # "HENRY Ⅷ"
586604 uc("tschüß") # "TSCHÜSS" notice ß => SS
587605
588606 # both are true:
589607 "tschüß" =~ /TSCHÜSS/i # notice ß => SS
590608 "Σίσυφος" =~ /ΣΊΣΥΦΟΣ/i # notice Σ,σ,ς sameness
591609
592610=head2 ℞ 21: Unicode case-insensitive comparisons
593611
594612(℞ 21: Unicode の大文字小文字を無視した比較)
595613
596614=begin original
597615
598616Also available in the CPAN L<Unicode::CaseFold> module,
599617the new C<fc> “foldcase” function from v5.16 grants
600618access to the same Unicode casefolding as the C</i>
601619pattern modifier has always used:
602620
603621=end original
604622
605623CPAN の L<Unicode::CaseFold> モジュールでも利用可能な、v5.16 の新しい
606624C<fc> "foldcase" 関数は、C</i> パターン修飾子が常に使ってきたのと同じ
607625Unicode 大文字小文字畳み込みへのアクセスを与えます。
608626
609627 use feature "fc"; # fc() function is from v5.16
610628
611629 # sort case-insensitively
612630 my @sorted = sort { fc($a) cmp fc($b) } @list;
613631
614632 # both are true:
615633 fc("tschüß") eq fc("TSCHÜSS")
616634 fc("Σίσυφος") eq fc("ΣΊΣΥΦΟΣ")
617635
618636=head2 ℞ 22: Match Unicode linebreak sequence in regex
619637
620638(℞ 22: 正規表現中の Unicode 改行並びのマッチング)
621639
622640=begin original
623641
624642A Unicode linebreak matches the two-character CRLF
625643grapheme or any of seven vertical whitespace characters.
626644Good for dealing with textfiles coming from different
627645operating systems.
628646
629647=end original
630648
631649Unicode の改行は、2 文字の CRLF 書記素または七つの垂直空白文字の
632650いずれかにマッチングします。
633651異なるオペレーティングシステムから送られてくるテキストファイルを
634652扱うのに適しています。
635653
636654 \R
637655
638656 s/\R/\n/g; # normalize all linebreaks to \n
639657
640658=head2 ℞ 23: Get character category
641659
642660(℞ 23: 文字カテゴリを得る)
643661
644662=begin original
645663
646664Find the general category of a numeric codepoint.
647665
648666=end original
649667
650668数値符号位置の一般カテゴリを見つけます。
651669
652670 use Unicode::UCD qw(charinfo);
653671 my $cat = charinfo(0x3A3)->{category}; # "Lu"
654672
655673=head2 ℞ 24: Disabling Unicode-awareness in builtin charclasses
656674
657675(℞ 24: 組み込み文字クラスで Unicode 判定を無効にする)
658676
659677=begin original
660678
661679Disable C<\w>, C<\b>, C<\s>, C<\d>, and the POSIX
662680classes from working correctly on Unicode either in this
663681scope, or in just one regex.
664682
665683=end original
666684
667685このスコープまたは一つの正規表現で、C<\w>、C<\b>、C<\s>、C<\d>、
668686および POSIX クラスが Unicode で正しく動作しないようにします。
669687
670688 use v5.14;
671689 use re "/a";
672690
673691 # OR
674692
675693 my($num) = $str =~ /(\d+)/a;
676694
677695=begin original
678696
679697Or use specific un-Unicode properties, like C<\p{ahex}>
680698and C<\p{POSIX_Digit>}. Properties still work normally
681699no matter what charset modifiers (C</d /u /l /a /aa>)
682700should be effect.
683701
684702=end original
685703
686704または、C<\p{ahex}> や C<\p{POSIX_Digit>} などの特定の非 Unicode 特性を
687705使います。
688706どの文字集合修飾子 (C</d /u /l /a /aa>) が有効であっても、
689707特性は正常に動作します。
690708
691709=head2 ℞ 25: Match Unicode properties in regex with \p, \P
692710
693711(℞ 25: 正規表現中に \p, \P を使って Unicode 特性にマッチングする)
694712
695713=begin original
696714
697715These all match a single codepoint with the given
698716property. Use C<\P> in place of C<\p> to match
699717one codepoint lacking that property.
700718
701719=end original
702720
703721これらはすべて、指定された特性を持つ一つの符号位置にマッチングします。
704722C<\p> の代わりに C<\P> を使用すると、その特性を持たない一つの符号位置に
705723マッチングします。
706724
707725 \pL, \pN, \pS, \pP, \pM, \pZ, \pC
708726 \p{Sk}, \p{Ps}, \p{Lt}
709727 \p{alpha}, \p{upper}, \p{lower}
710728 \p{Latin}, \p{Greek}
711 \p{script=Latin}, \p{script=Greek}
729 \p{script_extensions=Latin}, \p{scx=Greek}
712730 \p{East_Asian_Width=Wide}, \p{EA=W}
713731 \p{Line_Break=Hyphen}, \p{LB=HY}
714732 \p{Numeric_Value=4}, \p{NV=4}
715733
716734=head2 ℞ 26: Custom character properties
717735
718736(℞ 26: カスタム文字特性)
719737
720738=begin original
721739
722740Define at compile-time your own custom character
723741properties for use in regexes.
724742
725743=end original
726744
727745正規表現で使用する独自のカスタム文字特性をコンパイル時に定義します。
728746
729747 # using private-use characters
730748 sub In_Tengwar { "E000\tE07F\n" }
731749
732750 if (/\p{In_Tengwar}/) { ... }
733751
734752 # blending existing properties
735753 sub Is_GraecoRoman_Title {<<'END_OF_SET'}
736754 +utf8::IsLatin
737755 +utf8::IsGreek
738756 &utf8::IsTitle
739757 END_OF_SET
740758
741759 if (/\p{Is_GraecoRoman_Title}/ { ... }
742760
743761=head2 ℞ 27: Unicode normalization
744762
745763(℞ 27: Unicode 正規化)
746764
747765=begin original
748766
749767Typically render into NFD on input and NFC on output. Using NFKC or NFKD
750768functions improves recall on searches, assuming you've already done to the
751769same text to be searched. Note that this is about much more than just pre-
752770combined compatibility glyphs; it also reorders marks according to their
753771canonical combining classes and weeds out singletons.
754772
755773=end original
756774
757775通常は、入力では NFD に、出力では NFC にレンダリングされます。
758776NFKC または NFKD 関数を使うことで、検索対象の同じテキストに対して
759777既に実行していることを前提として、検索時の再呼び出しが改善されます。
760778これは単に事前結合された互換グリフ以上のものであることに
761779注意してください;
762780正準結合クラスに従ってマークを並び替え、シングルトンを削除します。
763781
764782 use Unicode::Normalize;
765783 my $nfd = NFD($orig);
766784 my $nfc = NFC($orig);
767785 my $nfkd = NFKD($orig);
768786 my $nfkc = NFKC($orig);
769787
770788=head2 ℞ 28: Convert non-ASCII Unicode numerics
771789
772790(℞ 28: 非 ASCII Unicode 数字を変換する)
773791
774792=begin original
775793
776794Unless you’ve used C</a> or C</aa>, C<\d> matches more than
777795ASCII digits only, but Perl’s implicit string-to-number
778796conversion does not current recognize these. Here’s how to
779797convert such strings manually.
780798
781799=end original
782800
783801C</a> や C</aa> を使用していない限り、C<\d> は ASCII 数字以上のものに
784802マッチングしますが、
785803Perl の暗黙的な文字列から数値への変換では、現在のところこれらを
786804認識できません。
787805このような文字列を手動で変換する方法を以下に示します。
788806
789807 use v5.14; # needed for num() function
790808 use Unicode::UCD qw(num);
791809 my $str = "got Ⅻ and ४५६७ and ⅞ and here";
792810 my @nums = ();
793811 while ($str =~ /(\d+|\N)/g) { # not just ASCII!
794812 push @nums, num($1);
795813 }
796814 say "@nums"; # 12 4567 0.875
797815
798816 use charnames qw(:full);
799817 my $nv = num("\N{RUMI DIGIT ONE}\N{RUMI DIGIT TWO}");
800818
801819=head2 ℞ 29: Match Unicode grapheme cluster in regex
802820
803821(℞ 29: 正規表現中の Unicode 書記素クラスタにマッチングする)
804822
805823=begin original
806824
807825Programmer-visible “characters” are codepoints matched by C</./s>,
808826but user-visible “characters” are graphemes matched by C</\X/>.
809827
810828=end original
811829
812830プログラマから見える「文字」は、C</./s> がマッチする符号位置ですが、
813831ユーザから見える「文字」は、C</\X/> がマッチする書記素です。
814832
815833 # Find vowel *plus* any combining diacritics,underlining,etc.
816834 my $nfd = NFD($orig);
817835 $nfd =~ / (?=[aeiou]) \X /xi
818836
819837=head2 ℞ 30: Extract by grapheme instead of by codepoint (regex)
820838
821839(℞ 30: 符号位置によってではなく、書記素によって展開する (正規表現))
822840
823841 # match and grab five first graphemes
824842 my($first_five) = $str =~ /^ ( \X{5} ) /x;
825843
826844=head2 ℞ 31: Extract by grapheme instead of by codepoint (substr)
827845
828846(℞ 31: 符号位置によってではなく、書記素によって展開する (substr))
829847
830848 # cpan -i Unicode::GCString
831849 use Unicode::GCString;
832850 my $gcs = Unicode::GCString->new($str);
833851 my $first_five = $gcs->substr(0, 5);
834852
835853=head2 ℞ 32: Reverse string by grapheme
836854
837855(℞ 32: 文字列を書記素単位で反転する)
838856
839857=begin original
840858
841859Reversing by codepoint messes up diacritics, mistakenly converting
842860C<crème brûlée> into C<éel̂urb em̀erc> instead of into C<eélûrb emèrc>;
843861so reverse by grapheme instead. Both these approaches work
844862right no matter what normalization the string is in:
845863
846864=end original
847865
848866符号位置による反転はダイアクリティカルマークを混乱させ、誤って
849867C<crème brülée> を C<eélûrb emèrc> ではなく
850868C<éel̂urb em̀erc> に変換します;
851869そこで、代わりに書記素による反転を行います。
852870これらの手法はどちらも、文字列の正規化がどのようなものであっても
853871正しく機能します。
854872
855873 $str = join("", reverse $str =~ /\X/g);
856874
857875 # OR: cpan -i Unicode::GCString
858876 use Unicode::GCString;
859877 $str = reverse Unicode::GCString->new($str);
860878
861879=head2 ℞ 33: String length in graphemes
862880
863881(℞ 33: 書記素での文字列長)
864882
865883=begin original
866884
867885The string C<brûlée> has six graphemes but up to eight codepoints.
868886This counts by grapheme, not by codepoint:
869887
870888=end original
871889
872890文字列 C<brülée> は六つの書記素を持ちますが、最大八つの符号位置を持ちます。
873891これは、符号位置ではなく、書記素によってカウントされます:
874892
875893 my $str = "brûlée";
876894 my $count = 0;
877895 while ($str =~ /\X/g) { $count++ }
878896
879897 # OR: cpan -i Unicode::GCString
880898 use Unicode::GCString;
881899 my $gcs = Unicode::GCString->new($str);
882900 my $count = $gcs->length;
883901
884902=head2 ℞ 34: Unicode column-width for printing
885903
886904(℞ 34: 表示のための Unicode 桁幅)
887905
888906=begin original
889907
890908Perl’s C<printf>, C<sprintf>, and C<format> think all
891909codepoints take up 1 print column, but many take 0 or 2.
892910Here to show that normalization makes no difference,
893911we print out both forms:
894912
895913=end original
896914
897915Perl の C<printf>、C<sprintf>、C<format> は、すべての符号位置が
898916一つの表示桁を占有すると考えていますが、多くの符号位置は 0 から 2 を
899917占有します。
900918ここでは、正規化に違いがないことを示すために、両方の形式を出力します。
901919
902920 use Unicode::GCString;
903921 use Unicode::Normalize;
904922
905923 my @words = qw/crème brûlée/;
906924 @words = map { NFC($_), NFD($_) } @words;
907925
908926 for my $str (@words) {
909927 my $gcs = Unicode::GCString->new($str);
910928 my $cols = $gcs->columns;
911929 my $pad = " " x (10 - $cols);
912930 say str, $pad, " |";
913931 }
914932
915933=begin original
916934
917935generates this to show that it pads correctly no matter
918936the normalization:
919937
920938=end original
921939
922940これは、正規化に関係なく正しくパッディングされていることを示すために
923941次のように生成されます。
924942
925943 crème |
926944 crème |
927945 brûlée |
928946 brûlée |
929947
930948=head2 ℞ 35: Unicode collation
931949
932950(℞ 35: Unicode の照合順序)
933951
934952=begin original
935953
936954Text sorted by numeric codepoint follows no reasonable alphabetic order;
937955use the UCA for sorting text.
938956
939957=end original
940958
941959数値符号位置でソートされたテキストは、合理的なアルファベット順ではありません;
942960テキストのソートには UCA を使用してください。
943961
944962 use Unicode::Collate;
945963 my $col = Unicode::Collate->new();
946964 my @list = $col->sort(@old_list);
947965
948966=begin original
949967
950968See the I<ucsort> program from the L<Unicode::Tussle> CPAN module
951969for a convenient command-line interface to this module.
952970
953971=end original
954972
955973このモジュールへの便利なコマンドラインインタフェースについては、
956974L<Unicode::Tassil> CPAN モジュールの I<ucsort> プログラムを参照してください。
957975
958976=head2 ℞ 36: Case- I<and> accent-insensitive Unicode sort
959977
960978(℞ 36: 大文字小文字 I<および> アクセントを無視した Unicode のソート)
961979
962980=begin original
963981
964982Specify a collation strength of level 1 to ignore case and
965983diacritics, only looking at the basic character.
966984
967985=end original
968986
969987照合強度レベル 1 を指定して、大文字小文字とダイアクリティカルマークを
970988無視し、基本文字だけを参照するようにします。
971989
972990 use Unicode::Collate;
973991 my $col = Unicode::Collate->new(level => 1);
974992 my @list = $col->sort(@old_list);
975993
976994=head2 ℞ 37: Unicode locale collation
977995
978996(℞ 37: Unicode ロケールの照合順序)
979997
980998=begin original
981999
9821000Some locales have special sorting rules.
9831001
9841002=end original
9851003
9861004一部のロケールには、特別なソート規則があります。
9871005
9881006 # either use v5.12, OR: cpan -i Unicode::Collate::Locale
9891007 use Unicode::Collate::Locale;
9901008 my $col = Unicode::Collate::Locale->new(locale => "de__phonebook");
9911009 my @list = $col->sort(@old_list);
9921010
9931011=begin original
9941012
9951013The I<ucsort> program mentioned above accepts a C<--locale> parameter.
9961014
9971015=end original
9981016
9991017上記の I<ucsort> プログラムは、C<--locale> パラメータを受け付けます。
10001018
10011019=head2 ℞ 38: Making C<cmp> work on text instead of codepoints
10021020
10031021(℞ 38: 符号位置ではなくテキストでg C<cmp> が動作するようにする)
10041022
10051023=begin original
10061024
10071025Instead of this:
10081026
10091027=end original
10101028
10111029次のようにせずに:
10121030
10131031 @srecs = sort {
10141032 $b->{AGE} <=> $a->{AGE}
10151033 ||
10161034 $a->{NAME} cmp $b->{NAME}
10171035 } @recs;
10181036
10191037=begin original
10201038
10211039Use this:
10221040
10231041=end original
10241042
10251043次を使います:
10261044
10271045 my $coll = Unicode::Collate->new();
10281046 for my $rec (@recs) {
10291047 $rec->{NAME_key} = $coll->getSortKey( $rec->{NAME} );
10301048 }
10311049 @srecs = sort {
10321050 $b->{AGE} <=> $a->{AGE}
10331051 ||
10341052 $a->{NAME_key} cmp $b->{NAME_key}
10351053 } @recs;
10361054
10371055=head2 ℞ 39: Case- I<and> accent-insensitive comparisons
10381056
10391057(℞ 39: 大文字小文字 I<および> アクセントを無視した比較)
10401058
10411059=begin original
10421060
10431061Use a collator object to compare Unicode text by character
10441062instead of by codepoint.
10451063
10461064=end original
10471065
10481066照合オブジェクトを使用して、Unicode テキストを符号位置ではなく
10491067文字で比較します。
10501068
10511069 use Unicode::Collate;
10521070 my $es = Unicode::Collate->new(
10531071 level => 1,
10541072 normalization => undef
10551073 );
10561074
10571075 # now both are true:
10581076 $es->eq("García", "GARCIA" );
10591077 $es->eq("Márquez", "MARQUEZ");
10601078
10611079=head2 ℞ 40: Case- I<and> accent-insensitive locale comparisons
10621080
10631081(℞ 40: 大文字小文字 I<および> アクセントを無視したロケールでの比較)
10641082
10651083=begin original
10661084
10671085Same, but in a specific locale.
10681086
10691087=end original
10701088
10711089同じですが、特定のロケールです。
10721090
10731091 my $de = Unicode::Collate::Locale->new(
10741092 locale => "de__phonebook",
10751093 );
10761094
10771095 # now this is true:
10781096 $de->eq("tschüß", "TSCHUESS"); # notice ü => UE, ß => SS
10791097
10801098=head2 ℞ 41: Unicode linebreaking
10811099
10821100(℞ 41: Unicode の改行)
10831101
10841102=begin original
10851103
10861104Break up text into lines according to Unicode rules.
10871105
10881106=end original
10891107
10901108Unicode 規則に従ってテキストを行に分割します。
10911109
10921110 # cpan -i Unicode::LineBreak
10931111 use Unicode::LineBreak;
10941112 use charnames qw(:full);
10951113
10961114 my $para = "This is a super\N{HYPHEN}long string. " x 20;
10971115 my $fmt = Unicode::LineBreak->new;
10981116 print $fmt->break($para), "\n";
10991117
11001118=head2 ℞ 42: Unicode text in DBM hashes, the tedious way
11011119
11021120(℞ 42: DBM ハッシュの中の Unicode テキスト、退屈な方法)
11031121
11041122=begin original
11051123
11061124Using a regular Perl string as a key or value for a DBM
11071125hash will trigger a wide character exception if any codepoints
11081126won’t fit into a byte. Here’s how to manually manage the translation:
11091127
11101128=end original
11111129
11121130DBM ハッシュのキーまたは値として通常の Perl 文字列を使用すると、
11131131符号位置が 1 バイトに収まらない場合にワイド文字例外が発生します。
11141132次に、手動で変換を管理する方法を示します:
11151133
11161134 use DB_File;
11171135 use Encode qw(encode decode);
11181136 tie %dbhash, "DB_File", "pathname";
11191137
11201138 # STORE
11211139
11221140 # assume $uni_key and $uni_value are abstract Unicode strings
11231141 my $enc_key = encode("UTF-8", $uni_key, 1);
11241142 my $enc_value = encode("UTF-8", $uni_value, 1);
11251143 $dbhash{$enc_key} = $enc_value;
11261144
11271145 # FETCH
11281146
11291147 # assume $uni_key holds a normal Perl string (abstract Unicode)
11301148 my $enc_key = encode("UTF-8", $uni_key, 1);
11311149 my $enc_value = $dbhash{$enc_key};
11321150 my $uni_value = decode("UTF-8", $enc_value, 1);
11331151
11341152=head2 ℞ 43: Unicode text in DBM hashes, the easy way
11351153
11361154(℞ 43: DBM ハッシュの中の Unicode テキスト、簡単な方法)
11371155
11381156=begin original
11391157
11401158Here’s how to implicitly manage the translation; all encoding
11411159and decoding is done automatically, just as with streams that
11421160have a particular encoding attached to them:
11431161
11441162=end original
11451163
11461164次に、変換を暗黙的に管理する方法を示します;
11471165すべてのエンコードとデコードは、特定のエンコーディングが付加された
11481166ストリームと同じように自動的に行われます:
11491167
11501168 use DB_File;
11511169 use DBM_Filter;
11521170
11531171 my $dbobj = tie %dbhash, "DB_File", "pathname";
11541172 $dbobj->Filter_Value("utf8"); # this is the magic bit
11551173
11561174 # STORE
11571175
11581176 # assume $uni_key and $uni_value are abstract Unicode strings
11591177 $dbhash{$uni_key} = $uni_value;
11601178
11611179 # FETCH
11621180
11631181 # $uni_key holds a normal Perl string (abstract Unicode)
11641182 my $uni_value = $dbhash{$uni_key};
11651183
11661184=head2 ℞ 44: PROGRAM: Demo of Unicode collation and printing
11671185
11681186(℞ 44: プログラム: Unicode の照合と表示のデモ)
11691187
11701188=begin original
11711189
11721190Here’s a full program showing how to make use of locale-sensitive
11731191sorting, Unicode casing, and managing print widths when some of the
11741192characters take up zero or two columns, not just one column each time.
11751193When run, the following program produces this nicely aligned output:
11761194
11771195=end original
11781196
11791197以下の完全なプログラムでは、ロケールを認識するソート、
11801198Unicode の大文字小文字、そしていくつかの文字が 1 桁ではなく 0 または 2 桁を
11811199占める場合の印刷幅の管理をどのように利用するかを示しています。
11821200次のプログラムを実行すると、次のようなうまく整列した出力が生成されます:
11831201
11841202 Crème Brûlée....... €2.00
11851203 Éclair............. €1.60
11861204 Fideuà............. €4.20
11871205 Hamburger.......... €6.00
11881206 Jamón Serrano...... €4.45
11891207 Linguiça........... €7.00
11901208 Pâté............... €4.15
11911209 Pears.............. €2.00
11921210 Pêches............. €2.25
11931211 Smørbrød........... €5.75
11941212 Spätzle............ €5.50
11951213 Xoriço............. €3.00
11961214 Γύρος.............. €6.50
11971215 막걸리............. €4.00
11981216 おもち............. €2.65
11991217 お好み焼き......... €8.00
12001218 シュークリーム..... €1.85
12011219 寿司............... €9.99
12021220 包子............... €7.50
12031221
12041222=begin original
12051223
1206Here's that program; tested on v5.14.
1224Here's that program.
12071225
12081226=end original
12091227
1210これがプログラムです; v5.14 でテストされています
1228これがプログラムです。
12111229
12121230 #!/usr/bin/env perl
12131231 # umenu - demo sorting and printing of Unicode food
12141232 #
12151233 # (obligatory and increasingly long preamble)
12161234 #
1235 use v5.36;
12171236 use utf8;
1218 use v5.14; # for locale sorting
1219 use strict;
1220 use warnings;
12211237 use warnings qw(FATAL utf8); # fatalize encoding faults
1222 use open qw(:std :utf8); # undeclared streams in UTF-8
1238 use open qw(:std :encoding(UTF-8)); # undeclared streams in UTF-8
12231239 use charnames qw(:full :short); # unneeded in v5.16
12241240
12251241 # std modules
12261242 use Unicode::Normalize; # std perl distro as of v5.8
12271243 use List::Util qw(max); # std perl distro as of v5.10
12281244 use Unicode::Collate::Locale; # std perl distro as of v5.14
12291245
12301246 # cpan modules
12311247 use Unicode::GCString; # from CPAN
12321248
1233 # forward defs
1234 sub pad($$$);
1235 sub colwidth(_);
1236 sub entitle(_);
1237
12381249 my %price = (
12391250 "γύρος" => 6.50, # gyros
12401251 "pears" => 2.00, # like um, pears
12411252 "linguiça" => 7.00, # spicy sausage, Portuguese
12421253 "xoriço" => 3.00, # chorizo sausage, Catalan
12431254 "hamburger" => 6.00, # burgermeister meisterburger
12441255 "éclair" => 1.60, # dessert, French
12451256 "smørbrød" => 5.75, # sandwiches, Norwegian
12461257 "spätzle" => 5.50, # Bayerisch noodles, little sparrows
12471258 "包子" => 7.50, # bao1 zi5, steamed pork buns, Mandarin
12481259 "jamón serrano" => 4.45, # country ham, Spanish
12491260 "pêches" => 2.25, # peaches, French
12501261 "シュークリーム" => 1.85, # cream-filled pastry like eclair
12511262 "막걸리" => 4.00, # makgeolli, Korean rice wine
12521263 "寿司" => 9.99, # sushi, Japanese
12531264 "おもち" => 2.65, # omochi, rice cakes, Japanese
12541265 "crème brûlée" => 2.00, # crema catalana
12551266 "fideuà" => 4.20, # more noodles, Valencian
12561267 # (Catalan=fideuada)
12571268 "pâté" => 4.15, # gooseliver paste, French
12581269 "お好み焼き" => 8.00, # okonomiyaki, Japanese
12591270 );
12601271
1261 my $width = 5 + max map { colwidth } keys %price;
1272 my $width = 5 + max map { colwidth($_) } keys %price;
12621273
12631274 # So the Asian stuff comes out in an order that someone
12641275 # who reads those scripts won't freak out over; the
12651276 # CJK stuff will be in JIS X 0208 order that way.
12661277 my $coll = Unicode::Collate::Locale->new(locale => "ja");
12671278
12681279 for my $item ($coll->sort(keys %price)) {
12691280 print pad(entitle($item), $width, ".");
12701281 printf " €%.2f\n", $price{$item};
12711282 }
12721283
1273 sub pad($$$) {
1284 sub pad ($str, $width, $padchar) {
1274 my($str, $width, $padchar) = @_;
12751285 return $str . ($padchar x ($width - colwidth($str)));
12761286 }
12771287
1278 sub colwidth(_) {
1288 sub colwidth ($str) {
1279 my($str) = @_;
12801289 return Unicode::GCString->new($str)->columns;
12811290 }
12821291
1283 sub entitle(_) {
1292 sub entitle ($str) {
1284 my($str) = @_;
12851293 $str =~ s{ (?=\pL)(\S) (\S*) }
12861294 { ucfirst($1) . lc($2) }xge;
12871295 return $str;
12881296 }
12891297
12901298=head1 SEE ALSO
12911299
12921300=begin original
12931301
12941302See these manpages, some of which are CPAN modules:
12951303L<perlunicode>, L<perluniprops>,
12961304L<perlre>, L<perlrecharclass>,
12971305L<perluniintro>, L<perlunitut>, L<perlunifaq>,
12981306L<PerlIO>, L<DB_File>, L<DBM_Filter>, L<DBM_Filter::utf8>,
12991307L<Encode>, L<Encode::Locale>,
13001308L<Unicode::UCD>,
13011309L<Unicode::Normalize>,
13021310L<Unicode::GCString>, L<Unicode::LineBreak>,
13031311L<Unicode::Collate>, L<Unicode::Collate::Locale>,
13041312L<Unicode::Unihan>,
13051313L<Unicode::CaseFold>,
13061314L<Unicode::Tussle>,
13071315L<Lingua::JA::Romanize::Japanese>,
13081316L<Lingua::ZH::Romanize::Pinyin>,
13091317L<Lingua::KO::Romanize::Hangul>.
13101318
13111319=end original
13121320
13131321以下の man ページ; 一部は CPAN モジュールのものです:
13141322L<perlunicode>, L<perluniprops>,
13151323L<perlre>, L<perlrecharclass>,
13161324L<perluniintro>, L<perlunitut>, L<perlunifaq>,
13171325L<PerlIO>, L<DB_File>, L<DBM_Filter>, L<DBM_Filter::utf8>,
13181326L<Encode>, L<Encode::Locale>,
13191327L<Unicode::UCD>,
13201328L<Unicode::Normalize>,
13211329L<Unicode::GCString>, L<Unicode::LineBreak>,
13221330L<Unicode::Collate>, L<Unicode::Collate::Locale>,
13231331L<Unicode::Unihan>,
13241332L<Unicode::CaseFold>,
13251333L<Unicode::Tussle>,
13261334L<Lingua::JA::Romanize::Japanese>,
13271335L<Lingua::ZH::Romanize::Pinyin>,
13281336L<Lingua::KO::Romanize::Hangul>.
13291337
13301338=begin original
13311339
13321340The L<Unicode::Tussle> CPAN module includes many programs
13331341to help with working with Unicode, including
13341342these programs to fully or partly replace standard utilities:
13351343I<tcgrep> instead of I<egrep>,
13361344I<uniquote> instead of I<cat -v> or I<hexdump>,
13371345I<uniwc> instead of I<wc>,
13381346I<unilook> instead of I<look>,
13391347I<unifmt> instead of I<fmt>,
13401348and
13411349I<ucsort> instead of I<sort>.
13421350For exploring Unicode character names and character properties,
13431351see its I<uniprops>, I<unichars>, and I<uninames> programs.
13441352It also supplies these programs, all of which are general filters that do Unicode-y things:
13451353I<unititle> and I<unicaps>;
13461354I<uniwide> and I<uninarrow>;
13471355I<unisupers> and I<unisubs>;
13481356I<nfd>, I<nfc>, I<nfkd>, and I<nfkc>;
13491357and I<uc>, I<lc>, and I<tc>.
13501358
13511359=end original
13521360
13531361L<Unicode::Tussle> CPAN モジュールには、Unicode を扱うための多くの
13541362プログラムが含まれています;
13551363これらのプログラムは、標準ユーティリティを完全にまたは部分的に
13561364置き換えるためのものです:
13571365I<egrep> の代わりに I<tcgrep>、
13581366I<cat -v> または I<hexdump> の代わりに I<uniquote>、
13591367I<wc> の代わりに I<uniwc>、
13601368I<look> の代わりに I<unilook>、
13611369I<fmt> の代わりに I<unifmt>、
13621370I<sort> の代わりに I<ucsort>。
13631371Unicode 文字名と文字特性を調べるには、I<uniprops>、I<unichars>、
13641372I<uninames> プログラムを参照してください。
13651373また、これらのプログラムも提供しています。
13661374これらはすべて Unicode 対応の一般的なフィルタです:
13671375I<unititle> と I<unicaps>、
13681376I<uniwide> と I<uninarrow>、
13691377I<unisupers> と I<unisubs>、
13701378I<nfd>、I<nfc>、I<nfkd>、I<nfkc>;
13711379I<uc>、I<lc>、I<tc>。
13721380
13731381=begin original
13741382
13751383Finally, see the published Unicode Standard (page numbers are from version
137613846.0.0), including these specific annexes and technical reports:
13771385
13781386=end original
13791387
13801388最後に、これらの特定の付属文書および技術報告書を含む、公開された
13811389Unicode 標準(ページ番号はバージョン6.0.0 から) を参照してください。
13821390
13831391=over
13841392
13851393=item §3.13 Default Case Algorithms, page 113;
13861394§4.2 Case, pages 120–122;
13871395Case Mappings, page 166–172, especially Caseless Matching starting on page 170.
13881396
13891397=item UAX #44: Unicode Character Database
13901398
13911399=item UTS #18: Unicode Regular Expressions
13921400
13931401=item UAX #15: Unicode Normalization Forms
13941402
13951403=item UTS #10: Unicode Collation Algorithm
13961404
13971405=item UAX #29: Unicode Text Segmentation
13981406
13991407=item UAX #14: Unicode Line Breaking Algorithm
14001408
14011409=item UAX #11: East Asian Width
14021410
14031411=back
14041412
14051413=head1 AUTHOR
14061414
14071415=begin original
14081416
14091417Tom Christiansen E<lt>tchrist@perl.comE<gt> wrote this, with occasional
14101418kibbitzing from Larry Wall and Jeffrey Friedl in the background.
14111419
14121420=end original
14131421
14141422Tom Christiansen E<lt>tchrist@perl.comE<gt> が、
14151423時々 Larry Wall と Jeffrey Friedl に後ろから口出しされながら書きました。
14161424
14171425=head1 COPYRIGHT AND LICENCE
14181426
14191427Copyright © 2012 Tom Christiansen.
14201428
14211429This program is free software; you may redistribute it and/or modify it
14221430under the same terms as Perl itself.
14231431
14241432=begin original
14251433
14261434Most of these examples taken from the current edition of the “Camel Book”;
14271435that is, from the 4ᵗʰ Edition of I<Programming Perl>, Copyright © 2012 Tom
14281436Christiansen <et al.>, 2012-02-13 by O’Reilly Media. The code itself is
14291437freely redistributable, and you are encouraged to transplant, fold,
14301438spindle, and mutilate any of the examples in this manpage however you please
14311439for inclusion into your own programs without any encumbrance whatsoever.
14321440Acknowledgement via code comment is polite but not required.
14331441
14341442=end original
14351443
14361444これらの例のほとんどは、"Camel Book"の現在の版から引用されています:
14371445すなわち、4ᵗʰ版I<Programming Perl>, Copyright © 2012 Tom
14381446Christiansen <et al.>, 2012-02-13 by O'Reilly Media。
14391447コード自体は自由に再配布可能であり、この man ページの例を移植したり、
14401448折りたたんだり、紡錘形にしたり、切断したりすることが推奨されますが、
14411449あなた自身のプログラムに含めるためには、何も気にせずに行ってください。
14421450コードコメントによる謝辞は丁寧ですが、必須ではありません。
14431451
14441452=head1 REVISION HISTORY
14451453
14461454=begin original
14471455
14481456v1.0.0 – first public release, 2012-02-27
14491457
14501458=end original
14511459
14521460v1.0.0 - 最初の一般公開、2012-02-27
14531461
14541462=begin meta
14551463
14561464Translate: SHIRAKATA Kentaro <argrath@ub32.org>
14571465Status: completed
14581466
14591467=end meta