作者suhang (suhang)
看板Python
標題[問題] Unicode Decode Error
時間Wed Oct 29 13:29:15 2014
我寫了一個crawler爬網頁
http://pastie.org/9682499#16,18
按照view page source <meta content="text/html; charset=Big5">
我用Big5 解碼回傳的 byte string
Python卻回應某些byte無法解碼
UnicodeDecodeError: 'big5' codec can't decode byte 0x82 in position 983:
illegal multibyte sequence
1
瀏覽器也是設定Big5解碼
那為什麼瀏覽器可以正確的顯現所有內容?
2
我試著用utf8瞎猜去解碼,一樣有error
請問我該如何處理這個錯誤而能顯示我所抓下來的網頁?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 76.169.54.91
※ 文章網址: http://www.ptt.cc/bbs/Python/M.1414560558.A.9C4.html
→ alibuda174: please provide more info, code, and error messages 10/29 13:41
已補上
※ 編輯: suhang (76.169.54.91), 10/29/2014 14:08:00
推 alibuda174: 0x82處於Big5編碼的使用者造字區裡 看來Python的 10/29 14:56
→ alibuda174: Big5 codec不支援這些東西 瀏覽器可正常顯示是因為 10/29 14:57
→ alibuda174: 它們也擴充支援那些字元了(Unicode補完計畫?) 10/29 14:57
→ alibuda174: 嗯 或許可以呼叫外部程式(能從Big5轉成utf8) 10/29 15:17