February 13, 2013 07:05PM
Using urldecode and declaring the charset, your example works on my server. It also works if you specify the encoding in the htmlentites:
<html>
<head>
<META http-equiv="content-type" content="text/html; charset=windows-1251">
</head>
<body>
<?php
echo urldecode($_GET['pol']);
?>
<br />
<?php
echo htmlspecialchars ( $_GET['pol'] , ENT_COMPAT | ENT_HTML401 , 'cp1251')
?>
</body>
</html>
I'm guessing your free hosting is Russian and their servers are setup with Russian character encodings (Apache's AddDefaultCharset maybe..? Sorry, I don't know too much about changing the default encoding on Apache.)
Its probably better to use the code above as it should work on any server as you are explicitly telling it what encoding to use rather than relying on the server.