.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PERLTW 1" .TH PERLTW 7 "2003-09-02" "perl v5.8.1" "Perl Programmers Reference Guide" .SH "NAME" perltw \- 正体中文 Perl 指南 .SH "DESCRIPTION" .IX Header "DESCRIPTION" 欢迎来到 Perl 的天地! .PP 从 5.8.0 版开始, Perl 具备了完善的 Unicode (万国码) 支援, 也连带支援了许e多拉丁语系以外的编码方式; \s-1CJK\s0 (中日韩) 便是其中的一部份. Unicode 是国际性的标准, 试图涵盖e世界上所有的字符: 西方世界, 东方世界, 以及两者间的一切 (希腊文, 叙利亚文, 阿拉伯文, 希伯来文, 印度文, 印地安文, 等等). 它也容纳了多种作业系统与平台 (如 \s-1PC\s0 及麦金塔). .PP Perl 本身以 Unicode 进行操作. 这表示 Perl 内部的字串资料可用 Unicode 表示; Perl 的函式与算符 (例如正规表示式比对) 也能对 Unicode 进行操作. 在输入及输出时, 为了处理以 Unicode 之前的编码方式储存的资料, Perl 提供了 Encode 这个模组, 可以让你轻易地读取及写入旧有的编码资料. .PP Encode 延伸模组支援下列正体中文的编码方式 ('big5' 表示 'big5\-eten'): .PP .Vb 3 \& big5-eten Big5 编码 (含倚天延伸字形) \& big5-hkscs Big5 + 香港外字集, 2001 年版 \& cp950 字码页 950 (Big5 + 微软添加的字符) .Ve .PP 举例来说, 将 Big5 编码的档案转成 Unicode, 祗需键入下列指令: .PP .Vb 1 \& perl -Mencoding=big5,STDOUT,utf8 -pe1 < file.big5 > file.utf8 .Ve .PP Perl 也内附了 \*(L"piconv\*(R", 一支完全以 Perl 写成的字符转换工具程式, 用法如下: .PP .Vb 2 \& piconv -f big5 -t utf8 < file.big5 > file.utf8 \& piconv -f utf8 -t big5 < file.utf8 > file.big5 .Ve .PP 另外, 利用 encoding 模组, 你可以轻易写出以字符为单位的程式码, 如下所示: .PP .Vb 7 \& #!/usr/bin/env perl \& # 启动 big5 字串解析; 标准输出入及标准错误都设为 big5 编码 \& use encoding 'big5', STDIN => 'big5', STDOUT => 'big5'; \& print length("骆驼"); # 2 (双引号表示字符) \& print length('骆驼'); # 4 (单引号表示位元组) \& print index("谆谆教诲", "彖帢"); # -1 (不包含此子字串) \& print index('谆谆教诲', '彖帢'); # 1 (从第二个位元组开始) .Ve .PP 在最后一列例子里, \*(L"谆\*(R" 的第二个位元组与 \*(L"谆\*(R" 的第一个位元组结合成 Big5 码的 \*(L"彖\*(R"; \*(L"谆\*(R" 的第二个位元组则与 \*(L"教\*(R" 的第一个位元组结合成 \*(L"帢\*(R". 这解决了以前 Big5 码比对处理上常见的问题. .Sh "额外的中文编码" .IX Subsection "额外的中文编码" 如果需要更多的中文编码, 可以从 \s-1CPAN\s0 () 下载 Encode::HanExtra 模组. 它目前提供下列编码方式: .PP .Vb 4 \& cccii 1980 年文建会的中文资讯交换码 \& euc-tw Unix 延伸字符集, 包含 CNS11643 平面 1-7 \& big5plus 中文数位化技术推广基金会的 Big5+ \& big5ext 中文数位化技术推广基金会的 Big5e .Ve .PP 另外, Encode::HanConvert 模组则提供了简繁转换用的两种编码: .PP .Vb 2 \& big5-simp Big5 正体中文与 Unicode 简体中文互转 \& gbk-trad GBK 简体中文与 Unicode 正体中文互转 .Ve .PP 若想在 \s-1GBK\s0 与 Big5 之间互转, 请参考该模组内附的 b2g.pl 与 g2b.pl 两支程式, 或在程式内使用下列写法: .PP .Vb 3 \& use Encode::HanConvert; \& $euc_cn = big5_to_gb($big5); # 从 Big5 转为 GBK \& $big5 = gb_to_big5($euc_cn); # 从 GBK 转为 Big5 .Ve .Sh "进一步的资讯" .IX Subsection "进一步的资讯" 请参考 Perl 内附的大量说明文件 (不幸全是用英文写的), 来学习更多关于 Perl 的知识, 以及 Unicode 的使用方式. 不过, 外部的资源相当丰富: .Sh "提供 Perl 资源的网址" .IX Subsection "提供 Perl 资源的网址" .IP "" 4 .IX Item "" Perl 的首页 (由欧莱礼公司维护) .IP "" 4 .IX Item "" Perl 综合典藏网 (Comprehensive Perl Archive Network) .IP "" 4 .IX Item "" Perl 邮递论坛一览 .Sh "学习 Perl 的网址" .IX Subsection "学习 Perl 的网址" .IP "" 4 .IX Item "" 正体中文版的欧莱礼 Perl 书藉 .IP "" 4 .IX Item "" 台湾 Perl 连线讨论区 (也就是各大 \s-1BBS\s0 的 Perl 连线版) .Sh "Perl 使用者集会" .IX Subsection "Perl 使用者集会" .IP "" 4 .IX Item "" 台湾 Perl 推广组一览 .IP "" 4 .IX Item "" 艺立协线上聊天室 .Sh "Unicode 相关网址" .IX Subsection "Unicode 相关网址" .IP "" 4 .IX Item "" Unicode 学术学会 (Unicode 标准的制定者) .IP "" 4 .IX Item "" Unix/Linux 上的 \s-1UTF\-8\s0 及 Unicode 答客问 .Sh "中文化资讯" .IX Subsection "中文化资讯" .ie n .IP "为什么叫 ""正体中文"" 不叫 ""繁体中文""?" 4 .el .IP "为什么叫 ``正体中文'' 不叫 ``繁体中文''?" 4 .IX Item "为什么叫 正体中文 不叫 繁体中文?" .IP "中文化软体联盟" 4 .IX Item "中文化软体联盟" .IP "Linux 软体中文化计划" 4 .IX Item "Linux 软体中文化计划" .SH "SEE ALSO" .IX Header "SEE ALSO" Encode, Encode::TW, encoding, perluniintro, perlunicode .SH "AUTHORS" .IX Header "AUTHORS" Jarkko Hietaniemi .PP Autrijus Tang (唐宗汉) .Sh "跋" .br 本页面中文版由中文 man 手册页计划提供。 .br 中文 man 手册页计划:\fBhttps://github.com/man-pages-zh/manpages-zh\fR