In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today Xiaobian to share with you Android HTTP request Chinese garbled how to solve the relevant knowledge points, detailed content, clear logic, I believe most people are still too familiar with this knowledge, so share this article for your reference, I hope you have read this article after harvest, let's learn about it together.
HTTP request Chinese garbled solution in Android
coding parameters
List formparams = new ArrayList(); //Request parameters for (NameValuePair p : params) { formparams.add(p); } UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams,HTTP.UTF_8); //Create POST request HttpPost httppost = new HttpPost(url); httppost.setEntity(entity);
Android sends HTTP requests, Android default encoding is utf-8.
Problem Description:
The request has been set to UTF-8 in the above code, and the code in the server is also all UTF-8, but the server obtains Chinese or garbled.
Since the server side is not developed by itself, it is impossible to see how the server works, only that the encoding is UTF-8.
The same server, iPhone client sends Chinese without garbled code.
Problem solving:
Try printing the HTTP header for Android,iPhone.
The content-types are different.
Andorid :content-type:application/x-www-form-urlencoded;IPHONE:content-type:application/x-www-form-urlencoded; charset=utf-8
So try to add a header to the request
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset= utf-8"); The above is "Android HTTP request Chinese garbled how to solve" All the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.