argra****@users*****
argra****@users*****
2009年 1月 17日 (土) 20:29:03 JST
Index: docs/perl/5.10.0/perlunifaq.pod diff -u docs/perl/5.10.0/perlunifaq.pod:1.2 docs/perl/5.10.0/perlunifaq.pod:1.3 --- docs/perl/5.10.0/perlunifaq.pod:1.2 Fri Jan 16 04:56:09 2009 +++ docs/perl/5.10.0/perlunifaq.pod Sat Jan 17 20:29:03 2009 @@ -391,11 +391,10 @@ =end original -It seemed like a good idea at the time, to keep the semantics the same for -standard strings, when Perl got Unicode support. While it might be repaired -in the future, we now have to deal with the fact that Perl treats equal -strings differently, depending on the internal state. -(TBT) +Perl が Unicode 対応になった時点では、これは標準文字列と同じ意味論を +維持するのにいい考えだと思われました。 +一方、これは将来修正されるかもしれないので、Perl が同じ文字列を内部状態に +よって異なる扱いをするという事実に対応する必要が出てきました。 =begin original @@ -529,10 +528,8 @@ =end original -This is a term used both for characters with an ordinal value greater than 127, -characters with an ordinal value greater than 255, or any character occupying -than one byte, depending on the context. -(TBT) +これは文脈に依存して、 127 より大きい序数を持つ文字、255 より大きい序数を +持つ文字、1 バイトで収まらない文字、のいずれかの意味で使われる用語です。 =begin original @@ -544,12 +541,12 @@ =end original -The Perl warning "Wide character in ..." is caused by a character with an -ordinal value greater than 255. With no specified encoding layer, Perl tries to -fit things in ISO-8859-1 for backward compatibility reasons. When it can't, it -emits this warning (if warnings are enabled), and outputs UTF-8 encoded data -instead. -(TBT) +Perl の警告 "Wide character in ..." は 255 より大きい序数を持つ文字によって +引き起こされます。 +エンコーディング層が指定されていない場合、Perl は過去互換性の理由によって +文字を ISO-8859-1 に合わせようとします。 +これができないと、(警告が有効なら)この警告が出力され、代わりに UTF-8 で +エンコードされたデータが出力されます。 =begin original @@ -558,9 +555,9 @@ =end original -To avoid this warning and to avoid having different output encodings in a single -stream, always specify an encoding explicitly, for example with a PerlIO layer: -(TBT) +この警告を回避し、一つのストリームに異なった出力エンコーディングが +出力されることを回避するには、常に明示的にエンコーディングを指定してください; +例えば PerlIO 層を使って: binmode STDOUT, ":encoding(UTF-8)"; @@ -580,10 +577,10 @@ =end original -Please, unless you're hacking the internals, or debugging weirdness, don't -think about the UTF8 flag at all. That means that you very probably shouldn't -use C<is_utf8>, C<_utf8_on> or C<_utf8_off> at all. -(TBT) +内部をハックしようとしているか、変なものをデバッグしようとしているのでない +限り、どうか UTF8 フラグのことは一切考えないでください。 +これは、まず間違いなく C<is_utf8>, C<_utf8_on>, C<_utf8_off> を +一切使うべきでないことを意味します。 =begin original @@ -593,10 +590,10 @@ =end original -The UTF8 flag, also called SvUTF8, is an internal flag that indicates that the -current internal representation is UTF-8. Without the flag, it is assumed to be -ISO-8859-1. Perl converts between these automatically. -(TBT) +UTF8 フラグ(SvUTF8 とも呼ばれます)は、現在の内部表現が UTF-8 であることを +示す内部フラグです。 +このフラグがない場合、ISO-8859-1 と仮定します。 +Perl はこれらを自動的に変換します。 =begin original @@ -607,11 +604,11 @@ =end original -One of Perl's internal formats happens to be UTF-8. Unfortunately, Perl can't -keep a secret, so everyone knows about this. That is the source of much -confusion. It's better to pretend that the internal format is some unknown -encoding, and that you always have to encode and decode explicitly. -(TBT) +Perl の内部表現の一つはたまたま UTF-8 です。 +残念ながら、Perl は秘密を守れないので、このことはみんな知っています。 +これが多くの混乱の源です。 +内部表現は何か分からないエンコーディングで、常に明示的にエンコードと +デコードが必要ということにしておいた方がよいです。 =head2 What about the C<use bytes> pragma? @@ -627,11 +624,11 @@ =end original これは使わないでください。 -It makes no sense to deal with bytes in a text string, and it -makes no sense to deal with characters in a byte string. Do the proper -conversions (by decoding/encoding), and things will work out well: you get -character counts for decoded data, and byte counts for encoded data. -(TBT) +テキスト文字列をバイト単位で扱うことに意味はありませんし、 +バイト文字列を文字単位で扱うことには意味はありません。 +適切な変換(デコードかエンコード)を行えば、物事はうまくいきます: +デコードしたデータの文字数を得られますし、エンコードしたデータのバイト数を +得られます。 =begin original @@ -640,9 +637,8 @@ =end original -C<use bytes> is usually a failed attempt to do something useful. Just forget -about it. -(TBT) +C<use bytes> は何か有用なことをしようとするためには間違った方法です。 +これのことは単に忘れてください。 =head2 What about the C<use encoding> pragma? @@ -658,11 +654,10 @@ =end original これは使わないでください。 -Unfortunately, it assumes that the programmer's environment and -that of the user will use the same encoding. It will use the same encoding for -the source code and for STDIN and STDOUT. When a program is copied to another -machine, the source code does not change, but the STDIO environment might. -(TBT) +残念ながら、これはプログラマの環境とユーザーの環境が同じであると仮定します。 +これはソースコードと STDIN や STDOUT で同じエンコーディングを使います。 +プログラムが他のマシンにコピーされると、ソースコードは変わりませんが、 +STDIO 環境は変わるかもしれません。 =begin original @@ -681,9 +676,8 @@ =end original -If you need to set the encoding for STDIN, STDOUT, and STDERR, for example -based on the user's locale, C<use open>. -(TBT) +もし STDIN, STDOUT, STDERR のエンコーディングを、例えばユーザーのロケールに +合わせてセットする必要があるなら、C<use open> してください。 =head2 What is the difference between C<:encoding> and C<:utf8>? @@ -712,12 +706,11 @@ C<:encoding(UTF-8)> の代わりに単に C<:utf8> を使うことで、もしデータが 内部で既に UTF8 で表現されていれば、エンコードの手順を省略します。 -This is -widely accepted as good behavior when you're writing, but it can be dangerous -when reading, because it causes internal inconsistency when you have invalid -byte sequences. Using C<:utf8> for input can sometimes result in security -breaches, so please use C<:encoding(UTF-8)> instead. -(TBT) +これは、書き込むときにはよい振る舞いであると広く受け入れられていますが、 +読み込むときには危険があります; なぜなら不正なバイト列を受け取ると +内部矛盾を引き起こすからです。 +入力に C<:utf8> を使うとセキュリティ侵害を引き起こす可能性があるので、 +どうか代わりに C<:encoding(UTF-8)> を使ってください。 =begin original