带有字符串实体的 HttpPost 具有特殊字符,如 ® ,看到 ¿1/2' 而不是 ®
2022-09-01 20:27:58
我需要使用特殊字符,如下所示。stringentity
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpEntity entity = new StringEntity("test®");
httpPost.setEntity(entity);
httpPost.setHeader("Accept-Encoding", "UTF-8");
HttpResponse response = httpClient.execute(httpPost);
BufferedReader reader = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
while ((reader.readLine()) != null) {
System.out.println (reader.readLine());
}
reader.close();
输出包含而不是在响应中。test�
test®