從http獲取請求獲取希伯來字符時出現問題。從http獲取非英文字符獲取請求
我得到像這樣的正方形字符:「[]」而不是希伯來字符。
英文字符正常。
這是我的函數:
public String executeHttpGet(String urlString) throws Exception {
BufferedReader in = null;
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(urlString));
HttpResponse response = client.execute(request);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),"UTF-8"));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String page = sb.toString();
// System.out.println(page);
return page;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
您可以測試是由這個例子網址:
String str = executeHttpGet("http://kavim-t.co.il/include/getXMLStations.asp?parent=7_%20_1");
謝謝!
你如何顯示接收到的文本?你確定它不僅僅是控制檯輸出的字體沒有這些字符嗎? – 2012-02-24 12:46:01
我使用textView來顯示收到的文本。但是在我處於調試模式之前,我甚至可以看到問題。 – David 2012-02-24 12:50:13
這也是我的假設。嘗試將網站保存到一個文件,然後用瀏覽器顯示它。如果這樣做,你很好。 – devsnd 2012-02-24 12:51:39