我正在尝试将下一个网页内容(原样)带到我的 Android 应用程序中的 TextView。
http://www.kavim-t.co.il/include/getXMLStations.asp?parent=56_%20_2
这是结果,Chrome 与 Activity:
如您所见,问题在于希伯来文/UTF-8/Windows-1255 字符显示为“???”。
我正在使用下一个代码(使用 org.apache.http):
TextView tv = (TextView) findViewById(R.id.tv1);
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8);
HttpGet request = new HttpGet("http://www.kavim-t.co.il/include/getXMLStations.asp?parent=56_%20_2");
HttpResponse response = null;
response = client.execute(request);
BufferedReader rd = null;
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
tv.append(line);
}
最佳答案
尝试为 InputStreamReader 指定字符集
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
关于java - 获取带有希伯来字符/UTF-8 的网页内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11470929/