source: trunk/third/perl/README.cn @ 20075

Revision 20075, 4.0 KB checked in by zacheiss, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20074, which included commits to RCS files with non-trunk default branches.
Line 
1If you read this file _as_is_, just ignore the funny characters you
2see. It is written in the POD format (see perlpod manpage) which is
3specially designed to be readable as is.
4
5The following documentation is written in EUC-CN encoding.
6
7Èç¹ûÄãÓÃÒ»°ãµÄÎÄ×ֱ༭Æ÷ÔÄÀÀÕâ·ÝÎļþ, ÇëºöÂÔÎÄÖÐÆæÌصÄ×¢¼Ç×Ö·û.
8Õâ·ÝÎļþÊÇÒÔ POD (¼òÃ÷Îļþ¸ñʽ) д³É; ÕâÖÖ¸ñʽÊÇΪÁËÄÜÈÃÈËÖ±½ÓÔĶÁ,
9¶øÌرðÉè¼ÆµÄ. ¹ØÓڴ˸ñʽµÄ½øÒ»²½ÐÅÏ¢, Çë²Î¿¼ perlpod ÏßÉÏÎļþ.
10
11=head1 NAME
12
13perlcn - ¼òÌåÖÐÎÄ Perl Ö¸ÄÏ
14
15=head1 DESCRIPTION
16
17»¶Ó­À´µ½ Perl µÄÌìµØ!
18
19´Ó 5.8.0 °æ¿ªÊ¼, Perl ¾ß±¸ÁËÍêÉÆµÄ Unicode (ͳһÂë) Ö§Ô®,
20Ò²Á¬´øÖ§Ô®ÁËÐí¶àÀ­¶¡ÓïϵÒÔÍâµÄ±àÂ뷽ʽ; CJK (ÖÐÈÕº«) ±ãÊÇÆäÖеÄÒ»²¿·Ý.
21Unicode Êǹú¼ÊÐԵıê×¼, ÊÔͼº­¸ÇÊÀ½çÉÏËùÓеÄ×Ö·û: Î÷·½ÊÀ½ç, ¶«·½ÊÀ½ç,
22ÒÔ¼°Á½Õß¼äµÄÒ»ÇÐ (Ï£À°ÎÄ, ÐðÀûÑÇÎÄ, ÑÇÀ­²®ÎÄ, Ï£²®À´ÎÄ, Ó¡¶ÈÎÄ,
23Ó¡µØ°²ÎÄ, µÈµÈ). ËüÒ²ÈÝÄÉÁ˶àÖÖ×÷ҵϵͳÓëƽ̨ (Èç PC ¼°Âó½ðËþ).
24
25Perl ±¾ÉíÒÔ Unicode ½øÐвÙ×÷. Õâ±íʾ Perl ÄÚ²¿µÄ×Ö·û´®Êý¾Ý¿ÉÓà Unicode
26±íʾ; Perl µÄº¯Ê½ÓëËã·û (ÀýÈçÕý¹æ±íʾʽ±È¶Ô) Ò²ÄÜ¶Ô Unicode ½øÐвÙ×÷.
27ÔÚÊäÈë¼°Êä³öʱ, ΪÁË´¦ÀíÒÔ Unicode ֮ǰµÄ±àÂ뷽ʽ´æ·ÅµÄÊý¾Ý, Perl
28ÌṩÁË Encode Õâ¸öÄ£¿é, ¿ÉÒÔÈÃÄãÇáÒ׵ضÁÈ¡¼°Ð´Èë¾ÉÓеıàÂëÊý¾Ý.
29
30Encode ÑÓÉìÄ£¿éÖ§Ô®ÏÂÁмòÌåÖÐÎĵıàÂ뷽ʽ ('gb2312' ±íʾ 'euc-cn'):
31
32    euc-cn      Unix ÑÓÉì×Ö·û¼¯, Ò²¾ÍÊÇË׳ƵĹú±êÂë
33    gb2312-raw  δ¾­´¦ÀíµÄ (µÍ±ÈÌØ) GB2312 ×Ö·û±í
34    gb12345     Î´¾­´¦ÀíµÄÖйúÓ÷±ÌåÖÐÎıàÂë
35    iso-ir-165  GB2312 + GB6345 + GB8565 + ÐÂÔö×Ö·û
36    cp936       ×ÖÂëÒ³ 936, Ò²¿ÉÒÔÓà 'GBK' (À©³ä¹ú±êÂë) Ö¸Ã÷
37    hz          7 ±ÈÌØÒݳöʽ GB2312 ±àÂë
38
39¾ÙÀýÀ´Ëµ, ½« EUC-CN ±àÂëµÄµµ°¸×ª³É Unicode, ìóÐè¼üÈëÏÂÁÐÖ¸Áî:
40
41    perl -Mencoding=euc-cn,STDOUT,utf8 -pe1 < file.euc-cn > file.utf8
42
43Perl Ò²ÄÚ¸½ÁË "piconv", Ò»Ö§ÍêÈ«ÒÔ Perl д³ÉµÄ×Ö·ûת»»¹¤¾ß³ÌÐò, Ó÷¨ÈçÏÂ:
44
45    piconv -f euc-cn -t utf8 < file.euc-cn > file.utf8
46    piconv -f utf8 -t euc-cn < file.utf8 > file.euc-cn
47
48ÁíÍâ, ÀûÓà encoding Ä£¿é, Äã¿ÉÒÔÇáÒ×д³öÒÔ×Ö·ûΪµ¥Î»µÄ³ÌÐòÂë, ÈçÏÂËùʾ:
49
50    #!/usr/bin/env perl
51    # Æô¶¯ euc-cn ×Ö´®½âÎö; ±ê×¼Êä³öÈë¼°±ê×¼´íÎó¶¼ÉèΪ euc-cn ±àÂë
52    use encoding 'euc-cn', STDIN => 'euc-cn', STDOUT => 'euc-cn';
53    print length("ÂæÍÕ");            #  2 (Ë«ÒýºÅ±íʾ×Ö·û)
54    print length('ÂæÍÕ');            #  4 (µ¥ÒýºÅ±íʾ×Ö½Ú)
55    print index("×»×»½Ì»å", "»×»½"); # -1 (²»°üº¬´Ë×Ó×Ö·û´®)
56    print index('×»×»½Ì»å', '»×»½'); #  1 (´ÓµÚ¶þ¸ö×Ö½Ú¿ªÊ¼)
57
58ÔÚ×îºóÒ»ÁÐÀý×ÓÀï, "×»" µÄµÚ¶þ¸ö×Ö½ÚÓë "×»" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É EUC-CN
59ÂëµÄ "»×"; "×»" µÄµÚ¶þ¸ö×Ö½ÚÔòÓë "½Ì" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É "»½".
60Õâ½â¾öÁËÒÔÇ° EUC-CN Âë±È¶Ô´¦ÀíÉϳ£¼ûµÄÎÊÌâ.
61
62=head2 ¶îÍâµÄÖÐÎıàÂë
63
64Èç¹ûÐèÒª¸ü¶àµÄÖÐÎıàÂë, ¿ÉÒÔ´Ó CPAN (L<http://www.cpan.org/>) ÏÂÔØ
65Encode::HanExtra Ä£¿é. ËüÄ¿Ç°ÌṩÏÂÁбàÂ뷽ʽ:
66
67    gb18030     À©³ä¹ýµÄ¹ú±êÂë, °üº¬·±ÌåÖÐÎÄ
68
69ÁíÍâ, Encode::HanConvert Ä£¿éÔòÌṩÁ˼ò·±×ª»»ÓõÄÁ½ÖÖ±àÂë:
70
71    big5-simp   Big5 ·±ÌåÖÐÎÄÓë Unicode ¼òÌåÖÐÎÄ»¥×ª
72    gbk-trad    GBK ¼òÌåÖÐÎÄÓë Unicode ·±ÌåÖÐÎÄ»¥×ª
73
74ÈôÏëÔÚ GBK Óë Big5 Ö®¼ä»¥×ª, Çë²Î¿¼¸ÃÄ£¿éÄÚ¸½µÄ b2g.pl Óë g2b.pl Á½Ö§³ÌÐò,
75»òÔÚ³ÌÐòÄÚʹÓÃÏÂÁÐд·¨:
76
77    use Encode::HanConvert;
78    $euc_cn = big5_to_gb($big5); # ´Ó Big5 תΪ GBK
79    $big5 = gb_to_big5($euc_cn); # ´Ó GBK תΪ Big5
80
81=head2 ½øÒ»²½µÄÐÅÏ¢
82
83Çë²Î¿¼ Perl ÄÚ¸½µÄ´óÁ¿ËµÃ÷Îļþ (²»ÐÒÈ«ÊÇÓÃÓ¢ÎÄдµÄ), À´Ñ§Ï°¸ü¶à¹ØÓÚ
84Perl µÄ֪ʶ, ÒÔ¼° Unicode µÄʹÓ÷½Ê½. ²»¹ý, ÍⲿµÄ×ÊÔ´Ï൱·á¸»:
85
86=head2 Ìṩ Perl ×ÊÔ´µÄÍøÖ·
87
88=over 4
89
90=item L<http://www.perl.com/>
91
92Perl µÄÊ×Ò³ (ÓÉÅ·À³Àñ¹«Ë¾Î¬»¤)
93
94=item L<http://www.cpan.org/>
95
96Perl ×ۺϵä²ØÍø (Comprehensive Perl Archive Network)
97
98=item L<http://lists.perl.org/>
99
100Perl ÓʵÝÂÛ̳һÀÀ
101
102=back
103
104=head2 ѧϰ Perl µÄÍøÖ·
105
106=over 4
107
108=item L<http://www.oreilly.com.cn/html/perl.html>
109
110¼òÌåÖÐÎÄ°æµÄÅ·À³Àñ Perl Êé½å
111
112=back
113
114=head2 Perl ʹÓÃÕß¼¯»á
115
116=over 4
117
118=item L<http://www.pm.org/groups/asia.shtml#China>
119
120Öйú Perl Íƹã×éÒ»ÀÀ
121
122=back
123
124=head2 Unicode Ïà¹ØÍøÖ·
125
126=over 4
127
128=item L<http://www.unicode.org/>
129
130Unicode ѧÊõѧ»á (Unicode ±ê×¼µÄÖƶ¨Õß)
131
132=item L<http://www.cl.cam.ac.uk/%7Emgk25/unicode.html>
133
134Unix/Linux É쵀 UTF-8 ¼° Unicode ´ð¿ÍÎÊ
135
136=back
137
138=head1 SEE ALSO
139
140L<Encode>, L<Encode::CN>, L<encoding>, L<perluniintro>, L<perlunicode>
141
142=head1 AUTHORS
143
144Jarkko Hietaniemi E<lt>jhi@iki.fiE<gt>
145
146Autrijus Tang (ÌÆ×Úºº) E<lt>autrijus@autrijus.orgE<gt>
147
148=cut
Note: See TracBrowser for help on using the repository browser.