【发布时间】:2013-03-10 12:04:46
【问题描述】:
我尝试发送字符串“Привет мир!”
String link = POST_URL;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(link);
String xml ="Привет мир";
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("file", xml));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
并通过php脚本保存:
if(!empty($_REQUEST['file'])){
$fp = fopen("C:\\windows\\temp\\1.xml", "w");
$mytext =$_POST["file"];
$test = fwrite($fp, $mytext);
fclose($fp);
但我明白了?????? ???在我的网络服务器上,我尝试使用 utf 编码重新打开文件,但它没有帮助。我该如何解决它。
【问题讨论】:
-
UrlEncodedFormEntity默认使用不支持俄语字符的ISO 8859-1编码。您可以在UrlEncodedFormEntity的构造函数中指定编码。new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8) -
非常感谢 :) @vmironov
标签: android