【问题标题】:Android Httppost and php, messy encodingAndroid Httppost 和 php,乱码
【发布时间】:2012-08-30 11:00:26
【问题描述】:

我有以下问题。我正在尝试在 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 字符都完全按照需要显示。我该怎么办?

【问题讨论】:

  • 任何特殊字符?
  • xml代码中乱七八糟的部分:%%%%%%(其中%——一些不可打印的字符),必须是география
  • 执行 urlencodedformentity 的部分可能会导致问题...我很确定这更适用于 http get 请求...我必须去查找几件事,秒。 ..

标签: php android encoding http-post utf


【解决方案1】:

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

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

【讨论】:

  • 附注我喜欢你的用户名:P
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    • 2010-09-25
    • 2014-10-28
    相关资源
    最近更新 更多