问题
i have these arabic sentence:
نايتيد أمامه عشرة أيام فقط لكي يقرر مستقبل برباتوف في النادي
It must be sent in the url. I tried this approach:
$url = 'http://example.com/?q='.urlencode('نايتيد أمامه عشرة أيام فقط لكي يقرر مستقبل برباتوف في النادي');
The result of that encoding is: %D9%86%D8%A7%D9%8A%D8%AA%D9%8A%D8%AF+%D8%A3%D9%85%D8%A7%D9%85%D9%87+%D8%B9%D8%B4%D8%B1%D8%A9+%D8%A3%D9%8A%D8%A7%D9%85+%D9%81%D9%82%D8%B7+%D9%84%D9%83%D9%8A+%D9%8A%D9%82%D8%B1%D8%B1+%D9%85%D8%B3%D8%AA%D9%82%D8%A8%D9%84+%D8%A8%D8%B1%D8%A8%D8%A7%D8%AA%D9%88%D9%81+%D9%81%D9%8A+%D8%A7%D9%84%D9%86%D8%A7%D8%AF%D9%8A
But the php script is receiving this in the $_GET['q'] querystring:
نايتيد أمامه عشرة أيام Ùقط لكي يقرر مستقبل برباتو٠ÙÙŠ النادي
The php file is UTF-8 encoded. Any ideas?
回答1:
You must urldecode your encoded entities. Furthermore remember that UTF8 and PHP are not a great combination.
回答2:
As I mention in other question, You should do urlencode the Arabic text
urlencode('كلام-عربي')
And its very important to add the charset code to the head tag of the page, otherwise the link will not work
<meta charset="utf-8">
回答3:
dont use urlencode just use rawurlencode
回答4:
As I mention in other question, You should do urldecode the Arabic text in URI
echo urldecode(explode('?', $_SERVER['REQUEST_URI'], 2));
来源:https://stackoverflow.com/questions/8591781/sending-arabic-characters-in-url