Submit Arabic characters in URL

I have this Arabic sentence:

Skip to content.

It must be sent to the url. I tried this approach:

$url = 'http://example.com/?q='.urlencode('نايتيد أمامه عشرة أيام فقط لكي يقرر مستقبل برباتوف في النادي'); 

The result of this encoding:% 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 gets this in $ _GET ['q'] querystring:

 نايتيد أمامه عشرة أيام Ùقط لكي يقرر مستقبل برباتو٠ÙÙŠ النادي 

The php file is encoded in UTF-8 encoding. Any ideas?

+4
source share
4 answers

You must urldecode your encoded objects. Also, remember that UTF8 and PHP are not a great combination.

+4
source

As I mentioned in another question, you should make urlencode arabic text

 urlencode('كلام-عربي') 

And it is very important to add the encoding code to the main page tag, otherwise the link will not work

 <meta charset="utf-8"> 
+2
source

Do not use urlencode, just use rawurlencode

+1
source

As I mentioned in another question, you should make urldecode arabic text in a URI

echo urldecode (explode ('?', $ _SERVER ['REQUEST_URI'], 2));

0
source

Source: https://habr.com/ru/post/1387395/


All Articles