0

我有以下问题。我正在尝试在 Android 中使用 httppost 发送数据(我的代码看起来像这样http://www.androidsnippets.com/executing-a-http-post-request-with-httpclient)。服务器使用php获取数据,代码如下:

<?php
$fileContents = $_POST["xml"];
$fileHandle = fopen("test.xml", 'w') or die("can't create file");
fprintf($fileHandle, "%s", $fileContents);
fclose($fileHandle);
?>

它工作正常,除了文件中的非 ascii 字符很乱。当我使用 php 脚本发送数据时 - 所有非 ascii 字符都完全按照需要显示。我该怎么办?

4

2 回答 2

1

像这样的东西应该可以解决问题,而不是 urlencodingformentity 的东西: http ://www.java-samples.com/showtutorial.php?tutorialid=735

我搜索了“java post utf8”以帮助找到这个潜在的解决方案,以防您需要查找更多详细信息。:)

于 2012-09-05T17:15:07.627 回答
0

您可以在发布的数据和 PHP 中设置 ut8(如果您想插入数据,也可以在数据库中)。我们没有您的代码来查看您发布的内容和方式,以便专门评论,但 UTF8 是要走的路

于 2012-09-05T18:40:00.840 回答