Add a test for [perl #17753].
[p5sagit/p5-mst-13.2.git] / README.cn
CommitLineData
d8416318 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
1d587bbd 7Èç¹ûÄãÓÃÒ»°ãµÄÎÄ×ֱ༭Æ÷ÔÄÀÀÕâ·ÝÎļþ, ÇëºöÂÔÎÄÖÐÆæÌصÄ×¢¼Ç×Ö·û.
8Õâ·ÝÎļþÊÇÒÔ POD (¼òÃ÷Îļþ¸ñʽ) д³É; ÕâÖÖ¸ñʽÊÇΪÁËÄÜÈÃÈËÖ±½ÓÔĶÁ,
f092799b 9¶øÌرðÉè¼ÆµÄ. ¹ØÓڴ˸ñʽµÄ½øÒ»²½ÐÅÏ¢, Çë²Î¿¼ perlpod ÏßÉÏÎļþ.
d8416318 10
11=head1 NAME
12
13perlcn - ¼òÌåÖÐÎÄ Perl Ö¸ÄÏ
14
15=head1 DESCRIPTION
16
17»¶Ó­À´µ½ Perl µÄÌìµØ!
18
f092799b 19´Ó 5.8.0 °æ¿ªÊ¼, Perl ¾ß±¸ÁËÍêÉÆµÄ Unicode (ͳһÂë) Ö§Ô®,
1d587bbd 20Ò²Á¬´øÖ§Ô®ÁËÐí¶àÀ­¶¡ÓïϵÒÔÍâµÄ±àÂ뷽ʽ; CJK (ÖÐÈÕº«) ±ãÊÇÆäÖеÄÒ»²¿·Ý.
f092799b 21Unicode Êǹú¼ÊÐԵıê×¼, ÊÔͼº­¸ÇÊÀ½çÉÏËùÓеÄ×Ö·û: Î÷·½ÊÀ½ç, ¶«·½ÊÀ½ç,
22ÒÔ¼°Á½Õß¼äµÄÒ»ÇÐ (Ï£À°ÎÄ, ÐðÀûÑÇÎÄ, ÑÇÀ­²®ÎÄ, Ï£²®À´ÎÄ, Ó¡¶ÈÎÄ,
1d587bbd 23Ó¡µØ°²ÎÄ, µÈµÈ). ËüÒ²ÈÝÄÉÁ˶àÖÖ×÷ҵϵͳÓëƽ̨ (Èç PC ¼°Âó½ðËþ).
d8416318 24
f092799b 25Perl ±¾ÉíÒÔ Unicode ½øÐвÙ×÷. Õâ±íʾ Perl ÄÚ²¿µÄ×Ö·û´®Êý¾Ý¿ÉÓà Unicode
1d587bbd 26±íʾ; Perl µÄº¯Ê½ÓëËã·û (ÀýÈçÕý¹æ±íʾʽ±È¶Ô) Ò²ÄÜ¶Ô Unicode ½øÐвÙ×÷.
27ÔÚÊäÈë¼°Êä³öʱ, ΪÁË´¦ÀíÒÔ Unicode ֮ǰµÄ±àÂ뷽ʽ´æ·ÅµÄÊý¾Ý, Perl
28ÌṩÁË Encode Õâ¸öÄ£¿é, ¿ÉÒÔÈÃÄãÇáÒ׵ضÁÈ¡¼°Ð´Èë¾ÉÓеıàÂëÊý¾Ý.
d8416318 29
ee081dd1 30Encode ÑÓÉìÄ£¿éÖ§Ô®ÏÂÁмòÌåÖÐÎĵıàÂ뷽ʽ ('gb2312' ±íʾ 'euc-cn'):
d8416318 31
32 euc-cn Unix ÑÓÉì×Ö·û¼¯, Ò²¾ÍÊÇË׳ƵĹú±êÂë
ee081dd1 33 gb2312-raw δ¾­´¦ÀíµÄ (µÍ±ÈÌØ) GB2312 ×Ö·û±í
d8416318 34 gb12345 δ¾­´¦ÀíµÄÖйúÓ÷±ÌåÖÐÎıàÂë
35 iso-ir-165 GB2312 + GB6345 + GB8565 + ÐÂÔö×Ö·û
ee081dd1 36 cp936 ×ÖÂëÒ³ 936, Ò²¿ÉÒÔÓà 'GBK' (À©³ä¹ú±êÂë) Ö¸Ã÷
d8416318 37 hz 7 ±ÈÌØÒݳöʽ GB2312 ±àÂë
38
1d587bbd 39¾ÙÀýÀ´Ëµ, ½« EUC-CN ±àÂëµÄµµ°¸×ª³É Unicode, ìóÐè¼üÈëÏÂÁÐÖ¸Áî:
d8416318 40
41 perl -Mencoding=euc-cn,STDOUT,utf8 -pe1 < file.euc-cn > file.utf8
42
1d587bbd 43Perl Ò²ÄÚ¸½ÁË "piconv", Ò»Ö§ÍêÈ«ÒÔ Perl д³ÉµÄ×Ö·ûת»»¹¤¾ß³ÌÐò, Ó÷¨ÈçÏÂ:
d8416318 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
1d587bbd 48ÁíÍâ, ÀûÓà encoding Ä£¿é, Äã¿ÉÒÔÇáÒ×д³öÒÔ×Ö·ûΪµ¥Î»µÄ³ÌÐòÂë, ÈçÏÂËùʾ:
d8416318 49
50 #!/usr/bin/env perl
1d587bbd 51 # Æô¶¯ euc-cn ×Ö´®½âÎö; ±ê×¼Êä³öÈë¼°±ê×¼´íÎó¶¼ÉèΪ euc-cn ±àÂë
f092799b 52 use encoding 'euc-cn', STDIN => 'euc-cn', STDOUT => 'euc-cn';
d8416318 53 print length("ÂæÍÕ"); # 2 (Ë«ÒýºÅ±íʾ×Ö·û)
ee081dd1 54 print length('ÂæÍÕ'); # 4 (µ¥ÒýºÅ±íʾ×Ö½Ú)
f092799b 55 print index("×»×»½Ì»å", "»×»½"); # -1 (²»°üº¬´Ë×Ó×Ö·û´®)
d8416318 56 print index('×»×»½Ì»å', '»×»½'); # 1 (´ÓµÚ¶þ¸ö×Ö½Ú¿ªÊ¼)
57
ee081dd1 58ÔÚ×îºóÒ»ÁÐÀý×ÓÀï, "×»" µÄµÚ¶þ¸ö×Ö½ÚÓë "×»" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É EUC-CN
59ÂëµÄ "»×"; "×»" µÄµÚ¶þ¸ö×Ö½ÚÔòÓë "½Ì" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É "»½".
f092799b 60Õâ½â¾öÁËÒÔÇ° EUC-CN Âë±È¶Ô´¦ÀíÉϳ£¼ûµÄÎÊÌâ.
61
d8416318 62=head2 ¶îÍâµÄÖÐÎıàÂë
63
1d587bbd 64Èç¹ûÐèÒª¸ü¶àµÄÖÐÎıàÂë, ¿ÉÒÔ´Ó CPAN (L<http://www.cpan.org/>) ÏÂÔØ
d8416318 65Encode::HanExtra Ä£¿é. ËüÄ¿Ç°ÌṩÏÂÁбàÂ뷽ʽ:
66
67 gb18030 À©³ä¹ýµÄ¹ú±êÂë, °üº¬·±ÌåÖÐÎÄ
68
69ÁíÍâ, Encode::HanConvert Ä£¿éÔòÌṩÁ˼ò·±×ª»»ÓõÄÁ½ÖÖ±àÂë:
70
d8416318 71 big5-simp Big5 ·±ÌåÖÐÎÄÓë Unicode ¼òÌåÖÐÎÄ»¥×ª
f092799b 72 gbk-trad GBK ¼òÌåÖÐÎÄÓë Unicode ·±ÌåÖÐÎÄ»¥×ª
d8416318 73
1d587bbd 74ÈôÏëÔÚ GBK Óë Big5 Ö®¼ä»¥×ª, Çë²Î¿¼¸ÃÄ£¿éÄÚ¸½µÄ b2g.pl Óë g2b.pl Á½Ö§³ÌÐò,
f092799b 75»òÔÚ³ÌÐòÄÚʹÓÃÏÂÁÐд·¨:
d8416318 76
f092799b 77 use Encode::HanConvert;
78 $euc_cn = big5_to_gb($big5); # ´Ó Big5 תΪ GBK
79 $big5 = gb_to_big5($euc_cn); # ´Ó GBK תΪ Big5
d8416318 80
f092799b 81=head2 ½øÒ»²½µÄÐÅÏ¢
82
1d587bbd 83Çë²Î¿¼ Perl ÄÚ¸½µÄ´óÁ¿ËµÃ÷Îļþ (²»ÐÒÈ«ÊÇÓÃÓ¢ÎÄдµÄ), À´Ñ§Ï°¸ü¶à¹ØÓÚ
d8416318 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
f092799b 138=head1 SEE ALSO
139
140L<Encode>, L<Encode::CN>, L<encoding>, L<perluniintro>, L<perlunicode>
141
d8416318 142=head1 AUTHORS
143
144Jarkko Hietaniemi E<lt>jhi@iki.fiE<gt>
145
ee081dd1 146Autrijus Tang (ÌÆ×Úºº) E<lt>autrijus@autrijus.orgE<gt>
d8416318 147
148=cut