Some version of internet explore (ie 11 and some other) giving wrong value like this ????????? for unicode variable. other than internet explorer, the code works fine. I have saved this file encoding as UTF-8 only. could any one help me please.
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function test(val){
var val;
//alert(val);
url=window.location.href="test.php?value="+val;
//alert(url);
}
</script>
</head>
<body>
<?php
$value="";
if(!empty($_GET['value'])){
echo $value=$_GET['value'];//this variable is the problem;
}
?>
<select style="width:180px;" onchange="test(this.value)">
<option value="">select</option>
<option value="நன்றி">நன்றி</option>
</select>
</body>
</html>
I think that’s rather your fault, because you are appending the value to the URL query string completely untreated. (That other browsers by chance do what you want, doesn’t necessarily mean it is right.)
Use encodeURIComponent
on the value before appending it.
Edit:
function test(val){
//var val; <- removed, because makes no sense - val gets passed in as parameter already
window.location.href = "test.php?value=" + encodeURIComponent(val);
}