Scroll to navigation

PERLTW(7) Perl Programmers Reference Guide PERLTW(7)
 

NAME

perltw - 正□中文 Perl 指南

DESCRIPTION

□迎□到 Perl 的天地!
□ 5.8.0 版□始, Perl 具□了完善的 Unicode (□□□) 支援, 也□□支援了□e多拉丁□系以外的□□方式; CJK (中日□) 便是其中的一部份. Unicode 是□□性的□□, □□涵□e世界上所有的字符: 西方世界, □方世界, 以及□者□的一切 (希□文, □利□文, 阿拉伯文, 希伯□文, 印度文, 印地安文, 等等). 它也容□了多□作□系□□平□ (如 PC 及□金塔).
Perl 本身以 Unicode □行操作. □表示 Perl □部的字串□料可用 Unicode 表示; Perl 的函式□算符 (例如正□表示式比□) 也能□ Unicode □行操作. 在□入及□出□, □了□理以 Unicode 之前的□□方式□存的□料, Perl 提供了 Encode □□模□, 可以□你□易地□取及□入□有的□□□料.
Encode 延伸模□支援下列正□中文的□□方式 ('big5' 表示 'big5-eten'):
    big5-eten   Big5 □□ (含倚天延伸字形)
    big5-hkscs  Big5 + 香港外字集, 2001 年版
    cp950       字□□ 950 (Big5 + 微□添加的字符)
□例□□, □ Big5 □□的□案□成 Unicode, 祗需□入下列指令:
    perl -Mencoding=big5,STDOUT,utf8 -pe1 < file.big5 > file.utf8
Perl 也□附了 "piconv", 一支完全以 Perl □成的字符□□工具程式, 用法如下:
    piconv -f big5 -t utf8 < file.big5 > file.utf8
    piconv -f utf8 -t big5 < file.utf8 > file.big5
另外, 利用 encoding 模□, 你可以□易□出以字符□□位的程式□, 如下所示:
    #!/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 (□第二□位元□□始)
在最後一列例子□, "□" 的第二□位元□□ "□" 的第一□位元□□合成 Big5 □的 "彖"; "□" 的第二□位元□□□ "教" 的第一□位元□□合成 "□". □解□了以前 Big5 □比□□理上常□的□□.
 
□外的中文□□
如果需要更多的中文□□, 可以□ CPAN (<http://www.cpan.org/>) 下□ Encode::HanExtra 模□. 它目前提供下列□□方式:
    cccii       1980 年文建□的中文□□交□□
    euc-tw      Unix 延伸字符集, 包含 CNS11643 平面 1-7
    big5plus    中文□位化技□推□基金□的 Big5+
    big5ext     中文□位化技□推□基金□的 Big5e
另外, Encode::HanConvert 模□□提供了□繁□□用的□□□□:
    big5-simp   Big5 正□中文□ Unicode □□中文互□
    gbk-trad    GBK □□中文□ Unicode 正□中文互□
若想在 GBK □ Big5 之□互□, □□考□模□□附的 b2g.pl □ g2b.pl □支程式, 或在程式□使用下列□法:
    use Encode::HanConvert;
    $euc_cn = big5_to_gb($big5); # □ Big5 □□ GBK
    $big5 = gb_to_big5($euc_cn); # □ GBK □□ Big5
 
□一步的□□
□□考 Perl □附的大量□明檔案 (不幸全是用英文□的), □□□更多□於 Perl 的知□, 以及 Unicode 的使用方式. 不□, 外部的□源相□□富:
 
提供 Perl □源的□址
<http://www.perl.com/>
Perl 的首□ (由□□□公司□□)
<http://www.cpan.org/>
Perl □合典藏□ (Comprehensive Perl Archive Network)
<http://lists.perl.org/>
Perl □□□□一□
 
□□ Perl 的□址
<http://www.oreilly.com.tw/chinese/perl/index.html>
正□中文版的□□□ Perl □藉
<http://groups.google.com/groups?q=tw.bbs.comp.lang.perl>
□□ Perl □□□□□ (也就是各大 BBS 的 Perl □□版)
 
Perl 使用者集□
<http://www.pm.org/groups/asia.shtml#Taiwan>
□□ Perl 推□□一□
<http://irc.elixus.org/>
□立□□上聊天室
 
Unicode 相□□址
<http://www.unicode.org/>
Unicode □□□□ (Unicode □□的制定者)
<http://www.cl.cam.ac.uk/%7Emgk25/unicode.html>
Unix/Linux 上的 UTF-8 及 Unicode 答客□
 
中文化□□
□什□叫 "正□中文" 不叫 "繁□中文"?
<http://www.csie.ntu.edu.tw/~b7506051/mozilla/faq.html#faqglossary>
中文化□□□盟
<http://www.cpatch.org/>
Linux □□中文化□□
<http://www.linux.org.tw/CLDP/>

SEE ALSO

Encode, Encode::TW, encoding, perluniintro, perlunicode

AUTHORS

Jarkko Hietaniemi <jhi@iki.fi>
Autrijus Tang (唐宗□) <autrijus@autrijus.org>
2003-09-02 perl v5.8.1