Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I finally resolved this, thank you all for some good tips (see last paragraph of this post for quick answer).</p> <p>I was doing a few things wrong that was making things difficult.</p> <p>I first noticed my encoding problems when records were not getting written to my database, the db and tables were all set to utf-8 so that left the php.</p> <p>To make things simple I created a test php page to demonstrate the problem. As the page was getting ($_GET) values from the url, when I loaded my test page, I did so with a unicode parameter in the url test.php?sText=Московский</p> <p>The problem for me, I think, was how IE was interoperating the url, for some reason it couldn't decode its or recognise it as unicode. This became aparrent when I launched the failing page im Chrome, and it worked perfectly.</p> <p>I proceeded to use the following function to output the full url in Chrome and IE </p> <pre><code>&lt;?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } echo curPageURL(); ?&gt; </code></pre> <p>Internet Explorer 8 echoed the following:</p> <blockquote> <p><a href="http://localhost/FirstProject/test.php?sText=" rel="nofollow noreferrer">http://localhost/FirstProject/test.php?sText=</a>?????????? </p> </blockquote> <p>Chrome however, echoed an encoded url:</p> <blockquote> <p><a href="http://localhost/FirstProject/test.php?sText=%D0%9C%D0%BE%D1%81%D0%BA%D0%BE%D0%B2%D1%81%D0%BA%D0%B8%D0%B9" rel="nofollow noreferrer">http://localhost/FirstProject/test.php?sText=%D0%9C%D0%BE%D1%81%D0%BA%D0%BE%D0%B2%D1%81%D0%BA%D0%B8%D0%B9</a></p> </blockquote> <p>As you can see chrome was encoding the url automatically, and PHP was automatically reading and decoding it correctly, presumably because I had set the content type to UTF-8 (thanks Philippe).</p> <p>I still wasn't sure why IE was behaving like this but it pushed me in the direction to encode the url in the calling page. I was calling the page in javascript so I tried the function <code>encodeURIComponent()</code>. Thankfully this worked and now im getting the same result in CHROME and IE.</p> <p>So long story short, if I use <code>encodeURIComponent()</code> for encoding the calling url an I ensure that I set the content type of the destination php page to <code>header('content-type: text/html; charset=utf-8');</code> all unicode url variables are processed correctly.</p> <p>Thanks again for all your help. Craig</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload