Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perljp.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLJP 1"
61 .TH PERLJP 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perljp \- 日本語 Perl ガイド
68 .SH 説明
69 .IX Header "説明"
70 Perl の世界へようこそ!
71 .PP
72 Perl 5.8.0 より、Unicodeサポートが大幅に強化され、その結果ラテン文字以外の文字コードのサポートが CJK (中国語、日本語、ハングル)を含めて加わりました。Unicodeは世界中の文字を一つの文字コードで扱うことを目指した標準規格であり、東から西、はたまたその間の文字(ギリシャ文字、キリール文字、アラビア文字、ヘブライ文字、ディーヴァナガーリ文字、などなど)や、これまではOSベンダーが独自に定めていた文字(PCおよびMacintosh)がすでに含まれています。
73 .PP
74 Perl 自身は Unicode で動作します。Perl スクリプト内の文字列リテラルや正規表現は Unicode を前提としています。そして入出力のためには、これまで使われてきたさまざまな文字コードに対応するモジュール、「 Encode 」が標準装備されており、Unicode とこれらの文字コードの相互変換も簡単に行えるようになっています。
75 .PP
76 現時点で Encode がサポートする文字コードは以下のとおりです。
77 .PP
78 .Vb 10
79 \& 7bit\-jis AdobeStandardEncoding AdobeSymbol AdobeZdingbat
80 \& ascii big5 big5\-hkscs cp1006
81 \& cp1026 cp1047 cp1250 cp1251
82 \& cp1252 cp1253 cp1254 cp1255
83 \& cp1256 cp1257 cp1258 cp37
84 \& cp424 cp437 cp500 cp737
85 \& cp775 cp850 cp852 cp855
86 \& cp856 cp857 cp860 cp861
87 \& cp862 cp863 cp864 cp865
88 \& cp866 cp869 cp874 cp875
89 \& cp932 cp936 cp949 cp950
90 \& dingbats euc\-cn euc\-jp euc\-kr
91 \& gb12345\-raw gb2312\-raw gsm0338 hp\-roman8
92 \& hz iso\-2022\-jp iso\-2022\-jp\-1 iso\-8859\-1
93 \& iso\-8859\-10 iso\-8859\-11 iso\-8859\-13 iso\-8859\-14
94 \& iso\-8859\-15 iso\-8859\-16 iso\-8859\-2 iso\-8859\-3
95 \& iso\-8859\-4 iso\-8859\-5 iso\-8859\-6 iso\-8859\-7
96 \& iso\-8859\-8 iso\-8859\-9 iso\-ir\-165 jis0201\-raw
97 \& jis0208\-raw jis0212\-raw johab koi8\-f
98 \& koi8\-r koi8\-u ksc5601\-raw MacArabic
99 \& MacCentralEurRoman MacChineseSimp MacChineseTrad MacCroatian
100 \& MacCyrillic MacDingbats MacFarsi MacGreek
101 \& MacHebrew MacIcelandic MacJapanese MacKorean
102 \& MacRoman MacRomanian MacRumanian MacSami
103 \& MacSymbol MacThai MacTurkish MacUkrainian
104 \& nextstep posix\-bc shiftjis symbol
105 \& UCS\-2BE UCS\-2LE UTF\-16 UTF\-16BE
106 \& UTF\-16LE UTF\-32 UTF\-32BE UTF\-32LE
107 \& utf8 viscii
108 .Ve
109 .PP
110 (全114種類)
111 .PP
112 例えば、文字コードFOOのファイルをUTF\-8に変換するには、以下のようにします。
113 .PP
114 .Vb 1
115 \& perl \-Mencoding=FOO,STDOUT,utf8 \-pe1 < file.FOO > file.utf8
116 .Ve
117 .PP
118 また、Perlには、全部がPerlで書かれた文字コード変換ユーティリティ、piconvも付属しているので、以下のようにすることもできます。
119 .PP
120 .Vb 2
121 \& piconv \-f FOO \-t utf8 < file.FOO > file.utf8
122 \& piconv \-f utf8 \-t FOO < file.utf8 > file.FOO
123 .Ve
124 .SS "(jcode.pl|Jcode.pm|JPerl) からの移行"
125 .IX Subsection "(jcode.pl|Jcode.pm|JPerl) からの移行"
126 5.8以前の、スクリプトがEUC\-JPであればリテラルだけは扱うことができました。また、入出力を扱うモジュールとしてはJcode.pmが( <http://openlab.ring.gr.jp/Jcode/> )、perl4用のユーティリティとしてはjcode.plがそれぞれ存在し、日本語の扱えるCGIでよく利用されていることを御存じの方も少なくないかと思われます。ただし、日本語による正規表現をうまく扱うことは不可能でした。
127 .PP
128 5.005以前のPerlには、日本語に特化したローカライズ版、Jperlが存在しました( <http://homepage2.nifty.com/kipp/perl/jperl/index.html> ※1)。また、Mac OS 9.x/Classic用のPerl、MacPerlの日本語版もMacJPerlとして存在してました。( <https://habilis.net/macjperl/> ).これらでは文字コードとしてEUC\-JPに加えShift_JISもそのまま扱うことができ、また日本語による正規表現を扱うことも可能でした。
129 .PP
130 Perl5.8では、これらの機能がすべてPerl本体だけで実現できる上に、日本語のみならず上記114の文字コードをすべて、しかも同時に扱うことができます。さらに、CPANなどから新しい文字コード用のモジュールを入手することも簡単にできるようになっています。
131 .PP
132 ※1: ホスティングサービスの終了により現在は閲覧できません。 Vector( <https://www.vector.co.jp/soft/win95/util/se098198.html> )からWindow用のバイナリを、CPAN( <https://www.cpan.org/src/unsupported/4.036/jperl/> )からperl4用のパッチを入手することができます。
133 .IP \(bu 4
134 入出力
135 .Sp
136 以下の例はいずれもShift_JISの入力をEUC\-JPに変換して出力します。
137 .Sp
138 .Vb 10
139 \& # jcode.pl
140 \& require "jcode.pl";
141 \& while(<>){
142 \& jcode::convert(*_, \*(Aqeuc\*(Aq, \*(Aqsjis\*(Aq);
143 \& print;
144 \& }
145 \& # Jcode.pm
146 \& use Jcode;
147 \& while(<>){
148 \& print Jcode\->new($_, \*(Aqsjis\*(Aq)\->euc;
149 \& }
150 \& # Perl 5.8
151 \& use Encode;
152 \& while(<>){
153 \& from_to($_, \*(Aqshiftjis\*(Aq, \*(Aqeuc\-jp\*(Aq);
154 \& print;
155 \& }
156 \& # Perl 5.8 \- encoding を利用して
157 \& use encoding \*(Aqeuc\-jp\*(Aq, STDIN => \*(Aqshiftjis\*(Aq;
158 \& while(<>){
159 \& print;
160 \& }
161 .Ve
162 .IP \(bu 4
163 Jperl 互換スクリプト
164 .Sp
165 いわゆる"shebang"を変更するだけで、Jperl用のscriptのほとんどは変更なしに利用可能だと思われます。
166 .Sp
167 .Vb 3
168 \& #!/path/to/jperl
169 \& ↓
170 \& #!/path/to/perl \-Mencoding=euc\-jp
171 .Ve
172 .Sp
173 詳しくは perldoc encoding を参照してください。
174 .SS さらに詳しく
175 .IX Subsection "さらに詳しく"
176 Perlには膨大な資料が付属しており、Perlの新機能やUnicodeサポート、そしてEncodeモジュールの使用法などが細かく網羅されています(残念ながら、ほとんど英語ではありますが)。以下のコマンドでそれらの一部を閲覧することが可能です。
177 .PP
178 .Vb 3
179 \& perldoc perlunicode # PerlのUnicodeサポート全般
180 \& perldoc Encode # Encodeモジュールに関して
181 \& perldoc Encode::JP # うち日本語文字コードに関して
182 .Ve
183 .SS "Perl全般に関する URL"
184 .IX Subsection "Perl全般に関する URL"
185 .IP <https://www.perl.org/> 4
186 .IX Item "<https://www.perl.org/>"
187 Perl ホームページ
188 .IP <https://www.perl.com/> 4
189 .IX Item "<https://www.perl.com/>"
190 Perl 財団が営業する文章作品集
191 .IP <https://www.cpan.org/> 4
192 .IX Item "<https://www.cpan.org/>"
193 CPAN (Comprehensive Perl Archive Network)
194 .IP <https://metacpan.org/> 4
195 .IX Item "<https://metacpan.org/>"
196 MetaCPAN CPANの検索エンジン
197 .IP <https://lists.perl.org/> 4
198 .IX Item "<https://lists.perl.org/>"
199 Perl メーリングリスト集
200 .IP <https://perldoc.jp/> 4
201 .IX Item "<https://perldoc.jp/>"
202 perldoc.jp Perl の公式ドキュメント、モジュールドキュメントの日本語訳
203 .SS "Perlの修得に役立つ URL"
204 .IX Subsection "Perlの修得に役立つ URL"
205 .IP <http://www.oreilly.com.cn/> 4
206 .IX Item "<http://www.oreilly.com.cn/>"
207 O\*(AqReilly 社のPerl関連書籍(簡体字中国語)
208 .IP <https://www.oreilly.co.jp/catalog/> 4
209 .IX Item "<https://www.oreilly.co.jp/catalog/>"
210 オライリー社のPerl関連書籍(日本語)
211 .SS "Perl に関する団体"
212 .IX Subsection "Perl に関する団体"
213 .IP <https://www.pm.org/groups/asia.html> 4
214 .IX Item "<https://www.pm.org/groups/asia.html>"
215 アジア地域の Perl Mongers (Perlのユーザーグループ) 一覧
216 .IP <https://japan.perlassociation.org> 4
217 .IX Item "<https://japan.perlassociation.org>"
218 一般社団法人Japan Perl Association (JPA) Perl技術及び文化の啓蒙・促進のための組織
219 .SS Unicode関連のURL
220 .IX Subsection "Unicode関連のURL"
221 .IP <https://www.unicode.org/> 4
222 .IX Item "<https://www.unicode.org/>"
223 Unicode コンソーシアム (Unicode規格の選定団体)
224 .IP <https://www.cl.cam.ac.uk/%7Emgk25/unicode.html> 4
225 .IX Item "<https://www.cl.cam.ac.uk/%7Emgk25/unicode.html>"
226 UTF\-8 and Unicode FAQ for Unix/Linux
227 .IP <https://wiki.kldp.org/Translations/html/UTF8\-Unicode\-KLDP/UTF8\-Unicode\-KLDP.html> 4
228 .IX Item "<https://wiki.kldp.org/Translations/html/UTF8-Unicode-KLDP/UTF8-Unicode-KLDP.html>"
229 UTF\-8 and Unicode FAQ for Unix/Linux (ハングル訳)
230 .SH AUTHORS
231 .IX Header "AUTHORS"
232 .IP \(bu 4
233 Jarkko Hietaniemi <[email protected]>
234 .IP \(bu 4
235 Dan Kogai (小飼 弾) <[email protected]>
236 .IP \(bu 4
237 Shogo Ichinose (一野瀬 翔吾) <[email protected]>