Home > Backend Development > PHP Problem > How to solve android php garbled code

How to solve android php garbled code

藏色散人
Release: 2023-03-11 19:46:02
Original
2465 people have browsed it

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

How to solve android php garbled code

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to solve the garbled code of android php?

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

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);
Copy after login

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();
Copy after login

Recommended learning: "PHP Video Tutorial"

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template