I m sending some form data (with get) to a popup with a javascript function. Both pages have utf-8 encoding. But popup showing special values wrong (like �). This problem happens on Internet Explorer only. It returns normal when i change ie encoding to windows-1254. Page encoding should stay same. Checked $_GET data with mb_detect_encoding(); it gives UTF-8 result. Any idea what can cause this?
function NewCustomer(field1,field2,field3){
OpenPopup('Customer/New.php?field1='+ field1 +'&field2='+ field2 +'&field3='+ field3 +'', 'NewCustomer', 'channelmode=0, directories=0, fullscreen=0, width=550, height=460, location=0, menubar=0, resizable=0, scrollbars=1, status=0, titlebar=1, toolbar=0', false);
}
echo $_GET['fieldname'];
function OpenPopup( url, winname, features )
{
if(winname==''){
window.open( url, winname, features, false );
return;
}
if ( !findWindow( url, winname, features ) )
{
var handle = window.open( url, winname, features, false );
if ( handle != null ) handle.focus();
}
}
function findWindow( url, winname, features )
{
var handle = window.open( '', winname, features, false );
if ( handle != null )
{
if (( handle.location != 'about:blank' ) && ( handle.location != '' ))
{
handle.focus();
return true;
}
}
return false;
}
EDIT
I fixed IE problem with iconv. But now, the problem started on other browsers.
iconv('windows-1254', 'UTF-8', $_GET['field']);
LAST EDIT
Here is final solution.
<?php if(isset($_GET['fieldname'])) {
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
if (count($matches)>1){ echo iconv('windows-1254', 'UTF-8', $_GET['fieldname']); } else { echo $_GET['fieldname']; }
} ?>