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