0

我正在研究 Android 中的基本 HTTP 请求响应示例。对于这个示例项目,我尝试使用 Google 翻译 URL。但是,其他语言的字符在响应中被垃圾或十六进制值替换。如果我从桌面浏览器点击 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. 

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

4

0 回答 0