Home >Backend Development >PHP Problem >How to solve the Chinese garbled problem in android php
Solution to Chinese garbled code in android php: 1. Fill in the corresponding format, code such as "httpResponse.getEntity()), HTTP.UTF_8"; 2. Use stream form, code such as "ttpResponse.getEntity( ).get...".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
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();
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to solve the Chinese garbled problem in android php. For more information, please follow other related articles on the PHP Chinese website!