1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see perlpod manpage) which is
3 specially designed to be readable as is.
5 The following documentation is written in EUC-CN encoding.
7 Èç¹ûÄãÓÃÒ»°ãµÄÎÄ×Ö±à¼Æ÷ÔÄÀÀÕâ·ÝÎļþ, ÇëºöÂÔÎÄÖÐÆæÌصÄ×¢¼Ç×Ö·û.
8 Õâ·ÝÎļþÊÇÒÔ POD (¼òÃ÷Îļþ¸ñʽ) д³É; ÕâÖÖ¸ñʽÊÇΪÁËÄÜÈÃÈËÖ±½ÓÔĶÁ,
9 ¶øÌرðÉè¼ÆµÄ. ¹ØÓڴ˸ñʽµÄ½øÒ»²½ÐÅÏ¢, Çë²Î¿¼ perlpod ÏßÉÏÎļþ.
13 perlcn - ¼òÌåÖÐÎÄ Perl Ö¸ÄÏ
19 ´Ó 5.8.0 °æ¿ªÊ¼, Perl ¾ß±¸ÁËÍêÉÆµÄ Unicode (ͳһÂë) Ö§Ô®,
20 Ò²Á¬´øÖ§Ô®ÁËÐí¶àÀ¶¡ÓïϵÒÔÍâµÄ±àÂ뷽ʽ; CJK (ÖÐÈÕº«) ±ãÊÇÆäÖеÄÒ»²¿·Ý.
21 Unicode Êǹú¼ÊÐԵıê×¼, ÊÔͼº¸ÇÊÀ½çÉÏËùÓеÄ×Ö·û: Î÷·½ÊÀ½ç, ¶«·½ÊÀ½ç,
22 ÒÔ¼°Á½Õß¼äµÄÒ»ÇÐ (Ï£À°ÎÄ, ÐðÀûÑÇÎÄ, ÑÇÀ²®ÎÄ, Ï£²®À´ÎÄ, Ó¡¶ÈÎÄ,
23 Ó¡µØ°²ÎÄ, µÈµÈ). ËüÒ²ÈÝÄÉÁ˶àÖÖ×÷ҵϵͳÓëƽ̨ (Èç PC ¼°Âó½ðËþ).
25 Perl ±¾ÉíÒÔ Unicode ½øÐвÙ×÷. Õâ±íʾ Perl ÄÚ²¿µÄ×Ö·û´®Êý¾Ý¿ÉÓà Unicode
26 ±íʾ; Perl µÄº¯Ê½ÓëËã·û (ÀýÈçÕý¹æ±íʾʽ±È¶Ô) Ò²ÄÜ¶Ô Unicode ½øÐвÙ×÷.
27 ÔÚÊäÈë¼°Êä³öʱ, ΪÁË´¦ÀíÒÔ Unicode ֮ǰµÄ±àÂ뷽ʽ´æ·ÅµÄÊý¾Ý, Perl
28 ÌṩÁË Encode Õâ¸öÄ£¿é, ¿ÉÒÔÈÃÄãÇáÒ׵ضÁÈ¡¼°Ð´Èë¾ÉÓеıàÂëÊý¾Ý.
30 Encode ÑÓÉìÄ£¿éÖ§Ô®ÏÂÁмòÌåÖÐÎĵıàÂ뷽ʽ ('gb2312' ±íʾ 'euc-cn'):
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 ±àÂë
39 ¾ÙÀýÀ´Ëµ, ½« EUC-CN ±àÂëµÄµµ°¸×ª³É Unicode, ìóÐè¼üÈëÏÂÁÐÖ¸Áî:
41 perl -Mencoding=euc-cn,STDOUT,utf8 -pe1 < file.euc-cn > file.utf8
43 Perl Ò²ÄÚ¸½ÁË "piconv", Ò»Ö§ÍêÈ«ÒÔ Perl д³ÉµÄ×Ö·ûת»»¹¤¾ß³ÌÐò, Ó÷¨ÈçÏÂ:
45 piconv -f euc-cn -t utf8 < file.euc-cn > file.utf8
46 piconv -f utf8 -t euc-cn < file.utf8 > file.euc-cn
48 ÁíÍâ, ÀûÓà encoding Ä£¿é, Äã¿ÉÒÔÇáÒ×д³öÒÔ×Ö·ûΪµ¥Î»µÄ³ÌÐòÂë, ÈçÏÂËùʾ:
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 (´ÓµÚ¶þ¸ö×Ö½Ú¿ªÊ¼)
58 ÔÚ×îºóÒ»ÁÐÀý×ÓÀï, "×»" µÄµÚ¶þ¸ö×Ö½ÚÓë "×»" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É EUC-CN
59 ÂëµÄ "»×"; "×»" µÄµÚ¶þ¸ö×Ö½ÚÔòÓë "½Ì" µÄµÚÒ»¸ö×Ö½Ú½áºÏ³É "»½".
60 Õâ½â¾öÁËÒÔÇ° EUC-CN Âë±È¶Ô´¦ÀíÉϳ£¼ûµÄÎÊÌâ.
64 Èç¹ûÐèÒª¸ü¶àµÄÖÐÎıàÂë, ¿ÉÒÔ´Ó CPAN (L<http://www.cpan.org/>) ÏÂÔØ
65 Encode::HanExtra Ä£¿é. ËüÄ¿Ç°ÌṩÏÂÁбàÂ뷽ʽ:
67 gb18030 À©³ä¹ýµÄ¹ú±êÂë, °üº¬·±ÌåÖÐÎÄ
69 ÁíÍâ, Encode::HanConvert Ä£¿éÔòÌṩÁ˼ò·±×ª»»ÓõÄÁ½ÖÖ±àÂë:
71 big5-simp Big5 ·±ÌåÖÐÎÄÓë Unicode ¼òÌåÖÐÎÄ»¥×ª
72 gbk-trad GBK ¼òÌåÖÐÎÄÓë Unicode ·±ÌåÖÐÎÄ»¥×ª
74 ÈôÏëÔÚ GBK Óë Big5 Ö®¼ä»¥×ª, Çë²Î¿¼¸ÃÄ£¿éÄÚ¸½µÄ b2g.pl Óë g2b.pl Á½Ö§³ÌÐò,
75 »òÔÚ³ÌÐòÄÚʹÓÃÏÂÁÐд·¨:
77 use Encode::HanConvert;
78 $euc_cn = big5_to_gb($big5); # ´Ó Big5 תΪ GBK
79 $big5 = gb_to_big5($euc_cn); # ´Ó GBK תΪ Big5
83 Çë²Î¿¼ Perl ÄÚ¸½µÄ´óÁ¿ËµÃ÷Îļþ (²»ÐÒÈ«ÊÇÓÃÓ¢ÎÄдµÄ), À´Ñ§Ï°¸ü¶à¹ØÓÚ
84 Perl µÄ֪ʶ, ÒÔ¼° Unicode µÄʹÓ÷½Ê½. ²»¹ý, ÍⲿµÄ×ÊÔ´Ï൱·á¸»:
86 =head2 Ìṩ Perl ×ÊÔ´µÄÍøÖ·
90 =item L<http://www.perl.com/>
92 Perl µÄÊ×Ò³ (ÓÉÅ·À³Àñ¹«Ë¾Î¬»¤)
94 =item L<http://www.cpan.org/>
96 Perl ×ۺϵä²ØÍø (Comprehensive Perl Archive Network)
98 =item L<http://lists.perl.org/>
104 =head2 ѧϰ Perl µÄÍøÖ·
108 =item L<http://www.oreilly.com.cn/html/perl.html>
110 ¼òÌåÖÐÎÄ°æµÄÅ·À³Àñ Perl Êé½å
114 =head2 Perl ʹÓÃÕß¼¯»á
118 =item L<http://www.pm.org/groups/asia.shtml#China>
124 =head2 Unicode Ïà¹ØÍøÖ·
128 =item L<http://www.unicode.org/>
130 Unicode ѧÊõѧ»á (Unicode ±ê×¼µÄÖƶ¨Õß)
132 =item L<http://www.cl.cam.ac.uk/%7Emgk25/unicode.html>
134 Unix/Linux É쵀 UTF-8 ¼° Unicode ´ð¿ÍÎÊ
140 L<Encode>, L<Encode::CN>, L<encoding>, L<perluniintro>, L<perlunicode>
144 Jarkko Hietaniemi E<lt>jhi@iki.fiE<gt>
146 Autrijus Tang (ÌÆ×Úºº) E<lt>autrijus@autrijus.orgE<gt>