我正在尝试从ActionScript向PHP发送请求,除了utf-8字符外,它还能正常工作。我的动作做了类似的事情:
var request:URLRequest = new URLRequest(url);
并且PHP端接收URL并对其进行处理(即将数据插入MySQL),如下所示:
$text = @$_GET['text'];
$text = urldecode($text);
$pdo->query("INSERT INTO mytable(thetext) VALUES ('$text')");
现在,当ActionScript中的变量URL为:
http://localhost/my_test_script.php?action=insert&text=non_utf_characters
我在MySQL表中看到正确插入了值"non_utf_characters"
。
但当网址是这样的时候:
http://localhost/my_test_script.php?action=insert&text=utf_characters_like_%C5%9E%C3%87%C3%96
它应该能够插入"utf_characters_like_ŞÇÖ"
,
但它只会插入"utf_characters_like_"
那么我应该怎样做才能让php从URL识别这些字符?
我尝试了什么:
urldecode()
header('Content-Type: text/plain; charset=utf-8');