Re: [問題] does not map to big5-eten

看板Perl作者 (System hacked)時間14年前 (2011/03/22 12:48), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
※ 引述《StarTouching (撫星)》之銘言: : 讓整個perl都支援unicode, 但對parse網頁來說 可能需要進一步判斷網頁編碼 : 另外parser本身是否可以判讀unicode也可能會是在我們無力控制的範圍 如果你是透過 HTTP::Response 取回資料,透過 decoded_content 可以取得 perl internal encoding,再轉成 utf8: my $data = Encode::encode('utf8', $response->decoded_content); : 只要能在程式中能識別出這樣的內碼, 那麼我們就可以選擇 避開 : 或是以big5既有的字符取代印出 (例如以一般空格取代無斷行空格) : 我測試了 s/\x{00a0}// 可以成功 : 但會有個額外的問題: : 這個做法能延伸到unicode的一段範圍嗎? 用 Encode::from_to($data, 'utf8', 'utf8') 硬轉,強制把 $data 濾乾淨... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.242.135.97
文章代碼(AID): #1DY2ehR- (Perl)
文章代碼(AID): #1DY2ehR- (Perl)