Home  >  Article  >  Backend Development  >  How to solve the problem of android php garbled characters

How to solve the problem of android php garbled characters

藏色散人
藏色散人Original
2020-08-15 10:20:562108browse

Solution to android php garbled code: 1. Fill in the corresponding format, such as "result= EntityUtils.toString(httpResponse.getEntity()), HTTP.UTF_8);"; 2. Use "stream" form to solve.

How to solve the problem of android php garbled characters

Recommendation: "PHP Video Tutorial"

Front-end and back-end interaction, android php solves the garbled problem

The first one: fill in the corresponding format

result= EntityUtils.toString(httpResponse.getEntity()),HTTP.UTF_8);
result=new String( EntityUtils.toString(httpResponse.getEntity()).getBytes("ISO_8859_1"),HTTP.UTF_8);

The second one: use the stream form

//通过流获取具体的内容
in = httpResponse.getEntity().getContent();
//创建缓冲区
BufferedReader br = new BufferedReader(new InputStreamReader(in));
sb = new StringBuffer();
String line = null;
while((line = br.readLine())!= null){
   sb.append(line);
}
result=sb.toString();

The above is the detailed content of How to solve the problem of android php garbled characters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn