看板 java 關於我們 聯絡資訊
目前我想修改良葛格的多人聊天Client程式(改在android平台上運行) 卡在說...在讀取伺服器端資料時...中文字會變成亂碼 程式碼如下 ------------這是讀入資料相關程式碼(ChatClientSocket.java)----------- skt = new Socket(host, port); // 從InputStream建立讀取緩衝區 theInputStream = new BufferedReader( new InputStreamReader(skt.getInputStream()),"BIG5"); //多加BIG5就OK了 // 讀取資料迴圈 while((message = theInputStream.readLine()) != null) { // 將之顯示在TextView上 message = ": " + message + "\n"; chatBox.UpdateTextView(); } -------------以下是更新UI的相關程式碼(Chat.java)------------ public static Handler mHandler = new Handler(); final Runnable mUpdateResults = new Runnable() { public void run() { update(); } }; public void UpdateTextView(){ mHandler.post(mUpdateResults); } //對textView進行更新 result=>是一個textView的物件 private void update() { result.append(clientSkt.getMessage()); } =========================================================== 不知道我觀念上哪裡出錯....不知道為什麼不會顯示正常中文 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.244.168.77
PsMonkey:雖然我不懂 Android,但是... 你有先搞懂 xxxxStream 嗎 08/15 19:08
PsMonkey:應該說,關鍵字是 encoding,剩下的請自己測... 08/15 19:09
lingerkptor:萬分感謝...我試成功了... 08/15 19:52
※ 編輯: lingerkptor 來自: 60.244.168.77 (08/15 19:54)
PsMonkey:以結果論是成功的,但是過程呢? 08/15 20:02