Php Android UTF-8西里尔文请求
在我的应用程序中,我从服务器请求数据以在用户配置文件视图中显示它。 应用程序读取JSON数据,解析并粘贴到表单字段中。字符集和应用程序读取西里尔字母字符串没有问题 尝试更新个人资料时出现问题:Php Android UTF-8西里尔文请求,php,android,json,utf-8,android-volley,Php,Android,Json,Utf 8,Android Volley,在我的应用程序中,我从服务器请求数据以在用户配置文件视图中显示它。 应用程序读取JSON数据,解析并粘贴到表单字段中。字符集和应用程序读取西里尔字母字符串没有问题 尝试更新个人资料时出现问题: JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, "http://meWebSite.com/userProfile.php?act=edit" +"&user_id="+user_i
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, "http://meWebSite.com/userProfile.php?act=edit"
+"&user_id="+user_id+
"&country="+country_1.getText().toString()+
"&city="+city_1.getText().toString(),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
parceEditingJsonRequest(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
JsonObjectRequest-request=新的JsonObjectRequest(request.Method.GET,”http://meWebSite.com/userProfile.php?act=edit"
+“&user\u id=“+user\u id+
“&country=“+country_1.getText().toString())+
“&city=“+city_1.getText().toString(),
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
parceEditingJsonRequest(响应);
}
},new Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
}
});
在这种情况下,所有西里尔文字符串看起来像
我打印了请求字符串并将其粘贴到浏览器-一切正常-西里尔文字符串已正确提交到服务器,所以我决定问题不在服务器端
我真的不知道从哪里开始。也许我应该为此请求指定字符集?请查看,即:
然后,如果需要,在服务器端,如果您使用的是php,则可以使用或。字符集需要指定为UTF-8,IDE也需要启用它。域和URL都不能包含任何非ASCII字符。。。但是这个问题被问了很多次。。。有一个解决方案解决方案在哪里?对不起,我不知道该怎么办-我需要全套的answer@LucasCrawford你有什么特点?有趣…尝试使用firebug或chrome inspect手动编辑您的个人资料页面,并输入一些西里尔字母,看看会发生什么。谢谢!它解决了我的问题!我还从org.apache.commons.lang.StringEscapeUtils中找到了使用escapeJava转换字符串的方法
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, "http://meWebSite.com/userProfile.php?act=edit"
+"&user_id="+URLEncoder.encode(user_id, "UTF-8")+
"&country="+URLEncoder.encode(country_1.getText().toString(), "UTF-8")+
"&city="+URLEncoder.encode(city_1.getText().toString(), "UTF-8"),