Re: [問題] 特殊的中文字
※ 引述《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)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 5 之 6 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章