note 61337 added to function.htmlentities
| From: | Bartek at osu1 dot php dot net | Date: | Tue, 31 Jan 2006 22:06:25 +0000 |
| Subject: | note 61337 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102786@lists.php.net to get a copy of this message | ||
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);
};
?>
----
Server IP: 81.223.254.85
Probable Submitter: 212.76.37.134
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61337
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61337&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61337&report=yes
Search -- http://master.php.net/manage/user-notes.php