note 61337 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:59:32 +0000 |
| Subject: | note 61337 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154921@lists.php.net to get a copy of this message | ||
Note Submitter: Bartek
----
I use this function to convert imput from MS Word into html (ascii) compatible output. I hope it
would work also for you.
I have enabled magic_quotes on my server so maybe you won't need stripslashes and addslashes.
I've also noticed that Opera 8.51 browses behaves somehow different from IE 6 and Firefox 1.5.
I haven't check this functions with other browsers.
<?php
function convert_word_to_ascii($string)
{
$string = stripslashes($string);
if ( stristr($_SERVER['HTTP_USER_AGENT'], "Opera") )
$search = array('‘',
chr(96),
'’',
'„',
'”',
'“',
'…',
'–');
if ( stristr($_SERVER['HTTP_USER_AGENT'], "Firefox") ||
stristr($_SERVER['HTTP_USER_AGENT'], "MSIE") )
$search = array(chr(145),
chr(146),
chr(96),
chr(132),
chr(147),
chr(148),
chr(133),
chr(150));
$replace = array( "'",
"'",
"'",
'"',
'"',
'"',
'...',
'-');
$new_string = str_replace($search, $replace, $string);
return addslashes($new_string);
};
?>