作者irenec (nickname)
看板perl
标题Re: [问题] 特殊的中文字
时间Tue Sep 9 14:50:38 2003
※ 引述《littleshan (我要加入剑道社!)》之铭言:
: 试试
: use utf8;
: open (SRC, "test.txt");
: binmode (SRC, ":encoding(big5)")
: binmode (SRC, ":encoding(big5)")
谢谢..
我把code改成:
use Text::ParseWords;
use utf16;
open (SRC,"test.txt"); #text.txt的内容是 "许正雄","名字许正雄"
binmode (SRC ":encoding(big5)");
while(<SRC>){
chomp;
print "$_\n";
@words = &parse_line('\,', 0, $_);
$i=0;
foreach(@words){
print "$words[$i]\n";
$i++;
}
}
close(SRC);
还是不行耶... 写法有问题吗 ?
这就是有名的「许功盖」吧... 从google找到一些说法(加\之类), 还是不work..
真是伤脑筋
: 这样子你就不需要encode和decode
: ※ 引述《irenec (nickname)》之铭言:
: : 我做了这样的测试:
: : use Encode;
: : use Text::ParseWords;
: : open (SRC,"test.txt");
: : while(<SRC>){
: : chomp;
: : $data = encode("utf8", $_);
: : @words = &parse_line('\,', 0, $data);
: : foreach(@words){
: : $output = decode("utf8", $_);
: : print "$_\n";
: $_的内容似乎是utf8 encoding
歹势, 是我疏忽.. 改成 print "$output\n"; 结果跟没encode/decode一样 ~_~
: : }
: : }
: : close(SRC);
: : 结果还是乱码... 是不是哪里错了 ?!
: : 把CSV解成ARRAY後, 做一些格式判断(RE), 然後塞入资料库
: : 目前的状况是做到CSV解开就卡住了.. >"<
--
irene's page
http://www.irenepage.idv.tw
※ 编辑: irenec 来自: 211.20.177.117 (09/09 14:51)