Bogey Posted June 23, 2015 Share Posted June 23, 2015 Hi all, When user fills in a e-acute (for example: test_é) then the "é" is shown in all browsers, except in IE. Any help would be appreciated Here is the code: index.php <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Test</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta http-equiv="Content-Language" content="nl"/> <meta name="robots" content="index,follow"/><meta name="description" content=""/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> <script>var xmlhttp;function run_xmlhttp(){if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else {// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}} function showPreview(sender, targetDiv){var name = document.getElementById(sender).value;alert(name);run_xmlhttp();xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(targetDiv).innerHTML=xmlhttp.responseText;}}xmlhttp.open('GET', 'showPreview.php?a=' + name, true);xmlhttp.send();}</script></head><body><div><div id='reviewFORM'><form id='' action=""><input type="text" id='inputIDname'/><button class="button radius" id='buttonsendReview' onclick="showPreview('inputIDname','reviewFORM')" tabindex='7' type='button' title=''>SEND (js)</button></form></div><!--<div><form id='' action="showPreview.php?a=test_é" method='POST'><input type="text" id='inputIDname'/><button type='submit' class="button radius" id='buttonsendReview' tabindex='7' type='button' title=''>SEND (php)</button></form></div>--></div></body></html> showPreview.php <?php$sender = stripslashes($_GET['a']);//$sender = str_replace('"',""",$afzender);//replace double quotes//$sender = preg_replace("/'/", "'", $afzender);//escape single quote //echo "nr1: " . htmlspecialchars($sender);//echo "<br />";echo "test: " . $sender;?> Link to comment Share on other sites More sharing options...
Bogey Posted June 23, 2015 Author Share Posted June 23, 2015 When user fills in: test_é other browsers prints: test: test_é (good) IE prints: test: test_ (without the é, what is not good) Link to comment Share on other sites More sharing options...
davej Posted June 23, 2015 Share Posted June 23, 2015 Rather than using... <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Test</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ...have you tried... <!DOCTYPE html><html lang="nl"><head><meta charset="utf-8"/><title>Test</title> Link to comment Share on other sites More sharing options...
Bogey Posted June 23, 2015 Author Share Posted June 23, 2015 just did... still the same... Link to comment Share on other sites More sharing options...
davej Posted June 23, 2015 Share Posted June 23, 2015 Do you see this in IE11 ? Link to comment Share on other sites More sharing options...
Bogey Posted June 23, 2015 Author Share Posted June 23, 2015 yes, I am running IE11 Link to comment Share on other sites More sharing options...
davej Posted June 23, 2015 Share Posted June 23, 2015 Yet you see it correctly in IE11 when you view your post in this forum, right? You had a simple form test commented out. Did it work? Did you perhaps try... <form id='form1' action="showPreview.php" method="POST"><input type="hidden" name="a" value="test_é"/> You might also want to look at... http://stackoverflow.com/questions/22632644/php-get-decode-utf-8 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 23, 2015 Share Posted June 23, 2015 Is that the only character with an issue? Link to comment Share on other sites More sharing options...
Ingolme Posted June 24, 2015 Share Posted June 24, 2015 The PHP file and the HTML page that is calling it should both share the same encoding, preferably UTF-8. The files need to be saved as UTF-8 in your text editor and then need to be served to the browser as UTF-8 using meta tags or HTTP headers. Link to comment Share on other sites More sharing options...
Bogey Posted July 2, 2015 Author Share Posted July 2, 2015 (edited) @davej: When viewing this post in IE11 then I see is correct; this works fine in IE11: <form id='testForm' action="showPreview.php" method="GET"><input name="a" value="test_é"/><button class="button radius" id='buttonsendReview' type='submit' title=''>SEND (js)</button></form> Returns: test: test_é @justsomeguy: For example test's returns ok, but á, à, é, è dont return. @ingolme: Al used files saved as UTF, but still no change.... or do I need the UTF-8 (no BOM)? Edited July 2, 2015 by Bogey Link to comment Share on other sites More sharing options...
Ingolme Posted July 2, 2015 Share Posted July 2, 2015 You're performing an AJAX request to showPreview.php, that file must also be saved in UTF-8. I believe it is preferable to save it without a byte-order mark, but I don't think it should really affect the outcome aside from having three extra characters at the beginning of the document. Link to comment Share on other sites More sharing options...
Bogey Posted July 3, 2015 Author Share Posted July 3, 2015 All files are saved UTF-8, so also showPreview.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now