PHP URL encoding / decoding – non-English languages

In Firefox when I send a GET request with parameters in Russian, the URL in the GET request looks like my_script.php?word=Цветок

  1. That does not look like what PHP urlencode() is supposed to return. I would expect that function to return what a browser would encode…. no? So what is the term for that type of encoding that the browser did (&#nnnn;)? Is it not URL encoding?

  2. On the server/PHP side, how can I decode that encoded word to the original language so I could save the original word in the database in a readable form? Is it possible to do without knowing the original language (Russian in my case) – since I may send GET requests with other languages.

  3. I have noticed that if I save those encoded words without any changes in the database, and then display these encoded strings in a web page, the browser knows by itself how to decode them back to the original language. Why does the browser do this decoding automatically? Can I control it?


Source: stackoverflow-php