具有不同语言字符的Android HTTP响应

时间:2014-08-04 08:56:56

标签: android encoding utf-8 httpclient httpentity

我正在开发Android中的基本HTTP请求响应示例。对于此示例项目,我尝试使用Google翻译网址。但是,响应中的其他语言的字符将替换为垃圾或十六进制值。如果我从桌面浏览器中点击URL,它可以正常工作。

以下是代码:

httpClient = new DefaultHttpClient();
httpGet = new HttpGet("https://translate.google.com/m?hl=en&sl=en&tl=gu&
    ie=UTF-8&prev=_m&q=sample") ;
httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity() ;
responseString = EntityUtils.toString( httpEntity, HTTP.UTF_8 );
// http response is all good except the characters that are in different 
// language are replaced by hex or junk characters. 

我做错了什么?有帮助吗?

0 个答案:

没有答案