Re: [問題] 特殊的中文字
※ 引述《littleshan (我要加入劍道社!)》之銘言:
: ※ 引述《irenec (nickname)》之銘言:
: : 含有「許」這個字的字串(我的狀況是用 Text::ParseWords解CSV檔得出欄位)
: : 會亂掉, 無法再作處理, 錯誤訊息似乎是多了一個Backslash
: : 但用RE濾並不work..
: : 請問該怎麼解決呢 ? 謝謝..
: 轉成utf8...是個方法
我做了這樣的測試:
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";
}
}
close(SRC);
結果還是亂碼... 是不是哪裡錯了 ?!
: 不曉得你想要做怎樣的處理?
把CSV解成ARRAY後, 做一些格式判斷(RE), 然後塞入資料庫
目前的狀況是做到CSV解開就卡住了.. >"<
--
irene's page http://www.irenepage.idv.tw
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 211.20.177.117
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章