オープンソース・ソフトウェアの開発とダウンロード

CVS リポジトリの参照

Diff of /perldocjp/docs/modules/MIME-Base64-2.12/Base64.pod

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by iwai, Thu Jan 27 13:14:57 2011 UTC revision 1.3 by argrath, Fri Sep 30 11:29:45 2022 UTC
# Line 1  Line 1 
1    
2  =encoding euc-jp  =encoding euc-jp
3    
4  =head1 名前  =head1 NAME
5    
6    =begin original
7    
8    MIME::Base64 - Encoding and decoding of base64 strings
9    
10    =end original
11    
12  MIME::Base64 - base64文字列のエンコードとデコード  MIME::Base64 - base64文字列のエンコードとデコード
13    
14  =head1 概要  =head1 SYNOPSIS
15    
16   use MIME::Base64;   use MIME::Base64;
17    
18   $encoded = encode_base64('Aladdin:open sesame');   $encoded = encode_base64('Aladdin:open sesame');
19   $decoded = decode_base64($encoded);   $decoded = decode_base64($encoded);
20    
21  =head1 説明  =head1 DESCRIPTION
22    
23    =begin original
24    
25    This module provides functions to encode and decode strings into the
26    Base64 encoding specified in RFC 2045 - I<MIME (Multipurpose Internet
27    Mail Extensions)>. The Base64 encoding is designed to represent
28    arbitrary sequences of octets in a form that need not be humanly
29    readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used,
30    enabling 6 bits to be represented per printable character.
31    
32    =end original
33    
34  このモジュールは RFC 2045 - I<MIME (Multipurpose Internet Mail Extensions)> の中で  このモジュールは RFC 2045 - I<MIME (Multipurpose Internet Mail Extensions)> の中で
35  定義されている Base64エンコード方式への文字列のエンコードとデコードを行なう関数を  定義されている Base64エンコード方式への文字列のエンコードとデコードを行なう関数を
# Line 20  MIME::Base64 - base64文字列のエンコード?/span> Line 37  MIME::Base64 - base64文字列のエンコード?/span>
37  任意のオクテット列を表現するのにデザインされています。65文字のUS-ASCIIのサブセット  任意のオクテット列を表現するのにデザインされています。65文字のUS-ASCIIのサブセット
38  ([A-Za-z0-9+/=])が使われ、1つの表示可能な文字に6ビットが割り当てられます。  ([A-Za-z0-9+/=])が使われ、1つの表示可能な文字に6ビットが割り当てられます。
39    
40    =begin original
41    
42    The following functions are provided:
43    
44    =end original
45    
46  以下の関数が提供されています:  以下の関数が提供されています:
47    
48  =over 4  =over 4
49    
50  =item encode_base64($str, [$eol])  =item encode_base64($str, [$eol])
51    
52    =begin original
53    
54    Encode data by calling the encode_base64() function.  The first
55    argument is the string to encode.  The second argument is the line
56    ending sequence to use (it is optional and defaults to C<"\n">).  The
57    returned encoded string is broken into lines of no more than 76
58    characters each and it will end with $eol unless it is empty.  Pass an
59    empty string as second argument if you do not want the encoded string
60    broken into lines.
61    
62    =end original
63    
64  encode_base64() 関数を呼び出す事によってデータをエンコードします。  encode_base64() 関数を呼び出す事によってデータをエンコードします。
65  最初の引数はエンコードされる文字列です。2番目の引数はシーケンスを終了する時に  最初の引数はエンコードされる文字列です。2番目の引数はシーケンスを終了する時に
66  使われる文字です(これはオプションで、デフォルトはC<"\n">です)。  使われる文字です(これはオプションで、デフォルトはC<"\n">です)。
# Line 35  encode_base64() 関数を呼び出す事によって Line 70  encode_base64() 関数を呼び出す事によって
70    
71  =item decode_base64($str)  =item decode_base64($str)
72    
73    =begin original
74    
75    Decode a base64 string by calling the decode_base64() function.  This
76    function takes a single argument which is the string to decode and
77    returns the decoded data.
78    
79    =end original
80    
81  decode_base64() 関数を呼び出す事によってデータをデコードします。  decode_base64() 関数を呼び出す事によってデータをデコードします。
82  この関数はデコードする文字列である単独の引数をとり、デコードしたデータを  この関数はデコードする文字列である単独の引数をとり、デコードしたデータを
83  返します。  返します。
84    
85    =begin original
86    
87    Any character not part of the 65-character base64 subset set is
88    silently ignored.  Characters occuring after a '=' padding character
89    are never decoded.
90    
91    =end original
92    
93  65文字のbase64サブセットの中にない文字は、単に無視されます。  65文字のbase64サブセットの中にない文字は、単に無視されます。
94  埋め込み文字'='の後ろは決してデコードされません。  埋め込み文字'='の後ろは決してデコードされません。
95    
96    =begin original
97    
98    If the length of the string to decode (after ignoring
99    non-base64 chars) is not a multiple of 4 or padding occurs too early,
100    then a warning is generated if perl is running under C<-w>.
101    
102    =end original
103    
104  もしデコードする文字列の長さが(base64文字以外を無視した後)  もしデコードする文字列の長さが(base64文字以外を無視した後)
105  4の整数倍数ではないか、埋め込み文字があまりにも早く見付かったならば、  4の整数倍数ではないか、埋め込み文字があまりにも早く見付かったならば、
106  perl が C<-w>で動作していると警告が表示されます。  perl が C<-w>で動作していると警告が表示されます。
107    
108  =back  =back
109    
110    =begin original
111    
112    If you prefer not to import these routines into your namespace you can
113    call them as:
114    
115    =end original
116    
117  これらの関数をあなたの名前空間にインポートすることを好ましく  これらの関数をあなたの名前空間にインポートすることを好ましく
118  思わないのであれば、以下のように呼ぶことが出来ます:  思わないのであれば、以下のように呼ぶことが出来ます:
119    
# Line 55  perl が C<-w>で動作していると警告が表示?/span> Line 121  perl が C<-w>で動作していると警告が表示?/span>
121      $encoded = MIME::Base64::encode($decoded);      $encoded = MIME::Base64::encode($decoded);
122      $decoded = MIME::Base64::decode($encoded);      $decoded = MIME::Base64::decode($encoded);
123    
124  =head1 診断  =head1 DIAGNOSTICS
125    
126    (診断)
127    
128    =begin original
129    
130    The following warnings might be generated if perl is invoked with the
131    C<-w> switch:
132    
133    =end original
134    
135  perlをC<-w>スイッチを付けて起動すると、以下の警告は表示されるかも  perlをC<-w>スイッチを付けて起動すると、以下の警告は表示されるかも
136  しれません:  しれません:
# Line 64  perlをC<-w>スイッチを付けて起動すると、?/span> Line 139  perlをC<-w>スイッチを付けて起動すると、?/span>
139    
140  =item Premature end of base64 data  =item Premature end of base64 data
141    
142  (訳注:Premature end of base64 data=base64データの終了が早すぎます)  =begin original
143    
144    The number of characters to decode is not a multiple of 4.  Legal
145    base64 data should be padded with one or two "=" characters to make
146    its length a multiple of 4.  The decoded result will anyway be as if
147    the padding was there.
148    
149    =end original
150    
151  デコードする文字の数が4の倍数ではありません。正しいbase64データは  デコードする文字の数が4の倍数ではありません。正しいbase64データは
152  長さが4の整数倍になるよう、1つまたは2つの"="文字で調整すべきです。  長さが4の整数倍になるよう、1つまたは2つの"="文字で調整すべきです。
# Line 73  perlをC<-w>スイッチを付けて起動すると、?/span> Line 155  perlをC<-w>スイッチを付けて起動すると、?/span>
155    
156  =item Premature padding of base64 data  =item Premature padding of base64 data
157    
158  (訳注:base64データの埋め込み文字が早すぎます)  =begin original
159    
160    The '=' padding character occurs as the first or second character
161    in a base64 quartet.
162    
163    =end original
164    
165  埋め込み文字'='が、base64の4文字の組での先頭または2番目として  埋め込み文字'='が、base64の4文字の組での先頭または2番目として
166  存在します。  存在します。
167    
168  =back  =back
169    
170  =head1 使用例  =head1 EXAMPLES
171    
172    =begin original
173    
174    If you want to encode a large file, you should encode it in chunks
175    that are a multiple of 57 bytes.  This ensures that the base64 lines
176    line up and that you do not end up with padding in the middle. 57
177    bytes of data fills one complete base64 line (76 == 57*4/3):
178    
179    =end original
180    
181  もしも大きなファイルをエンコードしたいのであれば、57バイトの固まりで  もしも大きなファイルをエンコードしたいのであれば、57バイトの固まりで
182  エンコードすべきです。これはbase64の行を確保し、中間の行が埋め込み文字で  エンコードすべきです。これはbase64の行を確保し、中間の行が埋め込み文字で
# Line 94  perlをC<-w>スイッチを付けて起動すると、?/span> Line 190  perlをC<-w>スイッチを付けて起動すると、?/span>
190         print encode_base64($buf);         print encode_base64($buf);
191     }     }
192    
193    =begin original
194    
195    or if you know you have enough memory
196    
197    =end original
198    
199  あるいは十分なメモリがあれば  あるいは十分なメモリがあれば
200    
201     use MIME::Base64 qw(encode_base64);     use MIME::Base64 qw(encode_base64);
202     local($/) = undef;  # slurp     local($/) = undef;  # slurp
203     print encode_base64(<STDIN>);     print encode_base64(<STDIN>);
204    
205    =begin original
206    
207    The same approach as a command line:
208    
209    =end original
210    
211  コマンド行からの同じアプローチは以下の通りです:  コマンド行からの同じアプローチは以下の通りです:
212    
213     perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' <file     perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' <file
214    
215    =begin original
216    
217    Decoding does not need slurp mode if all the lines contains a multiple
218    of 4 base64 chars:
219    
220    =end original
221    
222  すべての行にbase64文字が4の倍数入っていれば、デコードはslurpモードを  すべての行にbase64文字が4の倍数入っていれば、デコードはslurpモードを
223  必要としません:  必要としません:
224    
225     perl -MMIME::Base64 -ne 'print decode_base64($_)' <file     perl -MMIME::Base64 -ne 'print decode_base64($_)' <file
226    
227  =head1 著作権(=COPYRIGHT)  =head1 COPYRIGHT
228    
229  Copyright 1995-1999, 2001 Gisle Aas.  Copyright 1995-1999, 2001 Gisle Aas.
230    
231  This library is free software; you can redistribute it and/or  This library is free software; you can redistribute it and/or
232  modify it under the same terms as Perl itself.  modify it under the same terms as Perl itself.
233    
234    =begin original
235    
236  Distantly based on LWP::Base64 written by Martijn Koster  Distantly based on LWP::Base64 written by Martijn Koster
237  <m.koster@nexor.co.uk> and Joerg Reichelt <j.reichelt@nexor.co.uk> and  <m.koster@nexor.co.uk> and Joerg Reichelt <j.reichelt@nexor.co.uk> and
238  code posted to comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl> by Hans  code posted to comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl> by Hans
239  Mulder <hansm@wsinti07.win.tue.nl>  Mulder <hansm@wsinti07.win.tue.nl>
240    
241  The XS implementation use code from metamail.  Copyright 1991 Bell  =end original
 Communications Research, Inc. (Bellcore)  
242    
 参考訳(後半のみ):  
243  Martijn Koster<m.koster@nexor.co.uk> と  Martijn Koster<m.koster@nexor.co.uk> と
244  Joerg Reichelt <j.reichelt@nexor.co.uk>によって書かれたLWP::Base64、  Joerg Reichelt <j.reichelt@nexor.co.uk>によって書かれたLWP::Base64、
245  そしてHans Mulder <hansm@wsinti07.win.tue.nl>により  そしてHans Mulder <hansm@wsinti07.win.tue.nl>により
246  comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl>にポストされたコードを  comp.lang.perl <3pd2lp$6gf@wsinti07.win.tue.nl>にポストされたコードを
247  少しだけベースにしています。  少しだけベースにしています。
248    
249    =begin original
250    
251    The XS implementation use code from metamail.  Copyright 1991 Bell
252    Communications Research, Inc. (Bellcore)
253    
254    =end original
255    
256  XSの実装はmetamailのコードを使っています。  XSの実装はmetamailのコードを使っています。
257  Copyright 1991 Bell Communications Research, Inc. (Bellcore)  Copyright 1991 Bell Communications Research, Inc. (Bellcore)
258    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26