0
내 앱이 인터넷에 연결되어 페이지를 스크럽하여 이미지와 텍스트 같은 것을 얻도록 HTML을 얻습니다. 그러나 일부 구두점이 실제로 유니 코드 10 진수 코드로 변환되는 것을 보았습니다. 어쨌든이를 막으려 고합니다.구두점을 유니 코드로 변환하는 InputStream
public class DownloadPage extends AsyncTask<String, Void, String> {
public interface PageResponse {
void processFinish(String output);
}
private PageResponse delegate = null;
public DownloadPage(PageResponse delegate){
this.delegate = delegate;
}
@Override
protected String doInBackground(String... urls) {
URLConnection connection;
try {
URL url = new URL(urls[0]);
connection = url.openConnection();
String html;
InputStream inputStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder str = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
str.append(line);
}
inputStream.close();
html = str.toString();
return html;
} catch (MalformedURLException e) {
e.printStackTrace();
return "Failed";
} catch (IOException e) {
e.printStackTrace();
return "Failed";
}
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
delegate.processFinish(s);
}
}
이것은 https://www.looemusic.co.uk/news/에서 정보를 얻는 페이지입니다. 당신은 문제가 당신의 InputStreamReader의 캐릭터 세트 당신의 InputStream 함께, 아닌 HTML, 당신은 설정할 수 자체를 렌더링해야합니다 경우
This is what comes up with this code.
Charset.UTF-8을 좋아하지 않습니다. 옵션이 아닙니다. –