MIME-Base64-3.08 > 2.12 との差分

MIME::Base64 2.12 と 3.08 の差分

11
22=encoding euc-jp
33
44=head1 NAME
55
66=begin original
77
88MIME::Base64 - Encoding and decoding of base64 strings
99
1010=end original
1111
1212MIME::Base64 - base64文字列のエンコードとデコード
1313
1414=head1 SYNOPSIS
1515
1616 use MIME::Base64;
1717
1818 $encoded = encode_base64('Aladdin:open sesame');
1919 $decoded = decode_base64($encoded);
2020
2121=head1 DESCRIPTION
2222
2323=begin original
2424
25This module provides functions to encode and decode strings into the
25This module provides functions to encode and decode strings into and from the
26Base64 encoding specified in RFC 2045 - I<MIME (Multipurpose Internet
26base64 encoding specified in RFC 2045 - I<MIME (Multipurpose Internet
27Mail Extensions)>. The Base64 encoding is designed to represent
27Mail Extensions)>. The base64 encoding is designed to represent
2828arbitrary sequences of octets in a form that need not be humanly
2929readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used,
3030enabling 6 bits to be represented per printable character.
3131
3232=end original
3333
34このモジュールは RFC 2045 - I<MIME (Multipurpose Internet Mail Extensions)> の中で
34このモジュールはRFC 2045 -
35定義されている Base64エンコード方式への文字列のエンコードとデコードを行なう関数を
35I<MIME (Multipurpose Internet Mail Extensions)> で定義されている
36提供するモジュールです。Base64エンコード方式は人間の目に見えない、フォム中の
36base64 エンコーディングと文字列の間のエンコドとデコードを
37任意のオクテット列表現するのにデザインされています。65文字のUS-ASCIIのサブセット
37行なう関数提供するモジュールです。
38([A-Za-z0-9+/=])が使われ1つ表示可能な文字に6ビットが割り当てられます。
38base64 エンコーディングは任意オクテット列を、
39人間可読である必要のない形式で表現するために設計されています。
4065 文字の US-ASCII の部分集合 ([A-Za-z0-9+/=]) が使われ、一つの表示可能文字に
416 ビットが割り当てられます。
3942
4043=begin original
4144
4245The following functions are provided:
4346
4447=end original
4548
46以下の関数が提供されています:
49の関数が提供されています:
4750
4851=over 4
4952
50=item encode_base64($str, [$eol])
53=item encode_base64($str)
5154
55=item encode_base64($str, $eol);
56
5257=begin original
5358
5459Encode data by calling the encode_base64() function. The first
55argument is the string to encode. The second argument is the line
60argument is the string to encode. The second argument is the
56ending sequence to use (it is optional and defaults to C<"\n">). The
61line-ending sequence to use. It is optional and defaults to "\n". The
5762returned encoded string is broken into lines of no more than 76
5863characters each and it will end with $eol unless it is empty. Pass an
5964empty string as second argument if you do not want the encoded string
60broken into lines.
65to be broken into lines.
6166
6267=end original
6368
6469encode_base64() 関数を呼び出す事によってデータをエンコードします。
65最初の引数はエンコードされる文字列です。2番目の引数はシーケンスを終了する時に
70最初の引数はエンコードされる文字列です。
66使われる文字です(これはオプションで、デフォルトはC<"\n">です)
712 番目の引数はシーケンスを終了する時に使われる文字です。
67返さるエンコードされた文字列76文字を越えないように分割され
72れはオプションでデフォルトは "\n" です。
68空文字列でなけば$eolが最後に付きます。もしエンコードされた文字列を
73返さエンコードされた文字列は 76 文字越えないように分割され、
69複数の行に分割したくない場合は、2番目の引数として白の文字列を渡してください
74空文字列でなければ $eol が最後に付きます
75エンコードされた文字列を複数の行に分割したくない場合は、2 番目の引数として
76空文字列を渡してください。
7077
7178=item decode_base64($str)
7279
7380=begin original
7481
7582Decode a base64 string by calling the decode_base64() function. This
7683function takes a single argument which is the string to decode and
7784returns the decoded data.
7885
7986=end original
8087
8188decode_base64() 関数を呼び出す事によってデータをデコードします。
8289この関数はデコードする文字列である単独の引数をとり、デコードしたデータを
8390返します。
8491
8592=begin original
8693
87Any character not part of the 65-character base64 subset set is
94Any character not part of the 65-character base64 subset is
88silently ignored. Characters occuring after a '=' padding character
95silently ignored. Characters occurring after a '=' padding character
8996are never decoded.
9097
9198=end original
9299
9365文字のbase64サブセットの中にない文字は、単に無視されます。
10065 文字の base64 部分集合の中にない文字は、単に無視されます。
94込み文字'='の後ろは決してデコードされません。
101文字 '=' の後ろの文字は決してデコードされません。
95102
96103=begin original
97104
98If the length of the string to decode (after ignoring
105If the length of the string to decode, after ignoring
99non-base64 chars) is not a multiple of 4 or padding occurs too early,
106non-base64 chars, is not a multiple of 4 or if padding occurs too early,
100107then a warning is generated if perl is running under C<-w>.
101108
102109=end original
103110
104もしデコードする文字列の長さが(base64文字以外を無視した後)
111base64 文字以外を無視した後、デコードする文字列の長さが
1054の整数倍ではないか、込み文字があまりにも早く見付かったならば
1124 の整数倍ではないか、文字があまりにも早く見付かった場合
106perl が C<-w>で動作していると警告が表示されます。
113perl が C<-w> で動作していると警告が表示されます。
107114
108115=back
109116
110117=begin original
111118
112If you prefer not to import these routines into your namespace you can
119If you prefer not to import these routines into your namespace, you can
113120call them as:
114121
115122=end original
116123
117124これらの関数をあなたの名前空間にインポートすることを好ましく
118125思わないのであれば、以下のように呼ぶことが出来ます:
119126
120127 use MIME::Base64 ();
121128 $encoded = MIME::Base64::encode($decoded);
122129 $decoded = MIME::Base64::decode($encoded);
123130
124131=head1 DIAGNOSTICS
125132
126133(診断)
127134
128135=begin original
129136
130The following warnings might be generated if perl is invoked with the
137The following warnings can be generated if perl is invoked with the
131138C<-w> switch:
132139
133140=end original
134141
135perlをC<-w>スイッチを付けて起動すると、以下の警告は表示されるかも
142perl C<-w> スイッチを付けて起動すると、以下の警告
136れません:
143表示さることがあり:
137144
138145=over 4
139146
140147=item Premature end of base64 data
141148
142149=begin original
143150
144151The number of characters to decode is not a multiple of 4. Legal
145152base64 data should be padded with one or two "=" characters to make
146its length a multiple of 4. The decoded result will anyway be as if
153its length a multiple of 4. The decoded result will be the same
147the padding was there.
154whether the padding is present or not.
148155
149156=end original
150157
151デコードする文字の数が4の倍数ではありません。正しいbase64データは
158デコードする文字の数が 4 の倍数ではありません。
152長さが4の整数倍にるよう、1つまた2つの"="文字で調整すべきです。
159正当 base64 データ
153デコードの結果は、 埋め込み文字そこ存在するような形
160長さ 4 の整数倍るよう、一つまたは二つの "=" 文字調整されている
154行なわれます。
161必要があります。
162デコードの結果は、詰め物文字があるかどうかに関わらず同じです。
155163
156164=item Premature padding of base64 data
157165
158166=begin original
159167
160168The '=' padding character occurs as the first or second character
161169in a base64 quartet.
162170
163171=end original
164172
165込み文字'='が、base64の4文字の組での先頭または2番目として
173文字 '=' が、base64 4 文字の組での先頭または 2 番目として
166存在します。
174現れています。
167175
168176=back
169177
178=begin original
179
180The following exception can be raised:
181
182=end original
183
184次の例外が発生することがあります:
185
186=over 4
187
188=item Wide character in subroutine entry
189
190=begin original
191
192The string passed to encode_base64() contains characters with code
193above 255. The base64 encoding is only defined for single-byte
194characters. Use the Encode module to select the byte encoding you
195want.
196
197=end original
198
199encode_base64() に渡された文字列に、255 を超える符号位置を持つ文字が
200含まれています。
201base64 エンコーディングは単一バイト文字に対してのみ定義されています。
202求めているバイトエンコーディングを選ぶために Encode モジュールを
203使ってください。
204
205=back
206
170207=head1 EXAMPLES
171208
209(例)
210
172211=begin original
173212
174213If you want to encode a large file, you should encode it in chunks
175214that are a multiple of 57 bytes. This ensures that the base64 lines
176215line up and that you do not end up with padding in the middle. 57
177216bytes of data fills one complete base64 line (76 == 57*4/3):
178217
179218=end original
180219
181もしも大きなファイルをエンコードしたいのであれば、57バイトの固まりで
220大きなファイルをエンコードしたい場合57 バイトの倍数の固まりで
182エンコードすべきです。これはbase64の行を確保し、中間の行が埋め込み文字で
221エンコードすべきです。
183終わらないとを確実にします。57バイトのデータ1行の完全なbase64行
222 base64を確保し、中間の行が詰め物文字で
184(76 == 57*4/3)にます:
223終わらいことを保証にします
22457 バイトのデータは 1 行の完全な base64 行
225(76 == 57*4/3) になります:
185226
186227 use MIME::Base64 qw(encode_base64);
187228
188229 open(FILE, "/var/log/wtmp") or die "$!";
189230 while (read(FILE, $buf, 60*57)) {
190231 print encode_base64($buf);
191232 }
192233
193234=begin original
194235
195236or if you know you have enough memory
196237
197238=end original
198239
199あるいは十分なメモリがあれば
240あるいは十分なメモリがあれば:
200241
201242 use MIME::Base64 qw(encode_base64);
202243 local($/) = undef; # slurp
203244 print encode_base64(<STDIN>);
204245
205246=begin original
206247
207248The same approach as a command line:
208249
209250=end original
210251
211252コマンド行からの同じアプローチは以下の通りです:
212253
213254 perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' <file
214255
215256=begin original
216257
217Decoding does not need slurp mode if all the lines contains a multiple
258Decoding does not need slurp mode if every line contains a multiple
218of 4 base64 chars:
259of four base64 chars:
219260
220261=end original
221262
222すべての行にbase64文字が4の倍数入っていれば、デコードはslurpモードを
263すべての行に base64 文字が 4 の倍数入っていれば、デコードは
223必要としません:
264吸い込みモードを必要としません:
224265
225266 perl -MMIME::Base64 -ne 'print decode_base64($_)' <file
226267
268=begin original
269
270Perl v5.8 and better allow extended Unicode characters in strings.
271Such strings cannot be encoded directly, as the base64
272encoding is only defined for single-byte characters. The solution is
273to use the Encode module to select the byte encoding you want. For
274example:
275
276=end original
277
278Perl v5.8 以降では文字列に拡張 Unicode 文字を使えます。
279そのような文字列は直接エンコードできません;
280base64 エンコーディングは単一バイト文字に対してのみ定義されているからです。
281解決法は、求めているバイトエンコーディングを選ぶために Encode モジュールを
282使うことです。
283例えば:
284
285 use MIME::Base64 qw(encode_base64);
286 use Encode qw(encode);
287
288 $encoded = encode_base64(encode("UTF-8", "\x{FFFF}\n"));
289 print $encoded;
290
227291=head1 COPYRIGHT
228292
229Copyright 1995-1999, 2001 Gisle Aas.
293Copyright 1995-1999, 2001-2004 Gisle Aas.
230294
231295This library is free software; you can redistribute it and/or
232296modify it under the same terms as Perl itself.
233297
234298=begin original
235299
236300Distantly based on LWP::Base64 written by Martijn Koster
237301<m.koster@nexor.co.uk> and Joerg Reichelt <j.reichelt@nexor.co.uk> and
238302code posted to comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl> by Hans
239303Mulder <hansm@wsinti07.win.tue.nl>
240304
241305=end original
242306
243Martijn Koster<m.koster@nexor.co.uk> と
307Martijn Koster<m.koster@nexor.co.uk> と
244Joerg Reichelt <j.reichelt@nexor.co.uk>によって書かれたLWP::Base64、
308Joerg Reichelt <j.reichelt@nexor.co.uk>によって書かれた LWP::Base64、
245そしてHans Mulder <hansm@wsinti07.win.tue.nl>により
309そして Hans Mulder <hansm@wsinti07.win.tue.nl> により
246comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl>にポストされたコードを
310comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl>に投稿されたコードを
247311少しだけベースにしています。
248312
249313=begin original
250314
251The XS implementation use code from metamail. Copyright 1991 Bell
315The XS implementation uses code from metamail. Copyright 1991 Bell
252316Communications Research, Inc. (Bellcore)
253317
254318=end original
255319
256XSの実装はmetamailのコードを使っています。
320XS の実装は metamail のコードを使っています。
257321Copyright 1991 Bell Communications Research, Inc. (Bellcore)
258322
259=head1 翻訳者
323=head1 SEE ALSO
260324
261川合孝典 (GCD00051@nifty.ne.jp)
325L<MIME::QuotedPrint>
326
327=begin meta
328
329Translate: 川合孝典 <GCD00051@nifty.ne.jp>
330Update: Kentaro Shirakata <argrath@ub32.org> (3.08)
331Status: completed
332
333=end meta
334
335=cut