Jump to content

e-acute not showing


Bogey

Recommended Posts

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

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

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

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

  • 2 weeks later...

@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 by Bogey
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...