Re: [問題] 如何取得系統字元編碼或使用者輸入的編 …
※ 引述《Holocaust123 (奔跑的蝸牛)》之銘言:
: ※ 引述《mosquito520 ( )》之銘言:
: : 請教一下各位,
: : user_input = raw_input(["Search item"]).decode("編碼")
: : 我需要透過decode將輸入的資料正確的轉成utf8,
: : 但是在繁中WinXP底下透過sys.getdefaultencoding()取得編碼為Ascii,
: : 想請教一下,
: : 假設我希望可以處理多國語言,
: : 要如何取得正確的編碼順利的轉成utf8呢?
: : 謝謝:)
: import sys
: user_input = raw_input("Please input something: ")
: print user_input.decode(sys.stdin.encoding).encode('utf8')
感謝您的回答:)
這邊想再請問一點,
src = "文字"
dest = src.decode("big5") #代表將src從big5轉換為utf8放進dest
我目前也是這樣做
那為什麼還要再編碼為utf8呢?
抱歉新手上路問題比較多,還請見諒^^"
--
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
國 立 聯 合 大 學
(理工/電資/管理/技術/客家)院所 招生中
National United University
───────────────────────────────────
首頁 http://www.nuu.edu.tw BBS telnet://uun.twbbs.org
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.19.80
→
03/16 01:23, , 1F
03/16 01:23, 1F
→
03/16 01:24, , 2F
03/16 01:24, 2F
→
03/16 01:25, , 3F
03/16 01:25, 3F
→
03/16 01:52, , 4F
03/16 01:52, 4F
→
03/16 01:52, , 5F
03/16 01:52, 5F
→
03/16 01:53, , 6F
03/16 01:53, 6F
→
03/16 08:56, , 7F
03/16 08:56, 7F
→
03/18 14:19, , 8F
03/18 14:19, 8F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):