random1 Posted September 8, 2008 Share Posted September 8, 2008 How can you detect if a browser supports UTF8 using PHP? ??? I have my site set up properly for utf8 but want to be able to pick up browsers that don't support utf8. Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/ Share on other sites More sharing options...
DarkWater Posted September 8, 2008 Share Posted September 8, 2008 <?php if (strpos($_SERVER['HTTP_ACCEPT_CHARSET'], 'utf-8') !== FALSE) { //utf-8 good } Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/#findComment-637064 Share on other sites More sharing options...
random1 Posted September 9, 2008 Author Share Posted September 9, 2008 I now have: // Detecting if the browser supports UTF character set (required) if (strpos($_SERVER['HTTP_ACCEPT_CHARSET'], 'utf-8') !== FALSE) { echo 'true'; } else { echo 'false'; } and it is working in Firefox and Opera but not in Internet Explorer or Safari. Any suggestions. Internet Explorer and Safari show the notice: Notice: Undefined index: HTTP_ACCEPT_CHARSET in ........ Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/#findComment-637075 Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 Well that's quite a problem. Access this page in IE: <?php echo "<pre>" . print_r($_SERVER, true) . "</pre>"; ?> And show me the output. Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/#findComment-637081 Share on other sites More sharing options...
random1 Posted September 9, 2008 Author Share Posted September 9, 2008 Hmm.. $_SERVER does not contain anything about utf at all in Safari or IE. Maybe I'd need to check another way? I'll probably use a mix of this code and my browser detection to determine it. Thanks, help much appreciated Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/#findComment-637086 Share on other sites More sharing options...
DarkWater Posted September 9, 2008 Share Posted September 9, 2008 You could always supply multiple charsets in the meta tags (at least, I'm 99% sure that you can). <meta http-equiv="content-type" content="text/html; charset=utf-8,iso-8859-1" /> Link to comment https://forums.phpfreaks.com/topic/123346-detecting-utf8-browser-support/#findComment-637093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.