Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2008, 10:20 PM
Registered User
 
Join Date: Mar 2004
Location: Mumbai, Maharastra, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default code to remove ms word special characters

I found following code while googling

after using this code I am getting what I want still
I have a small problem to solve

I cannot control the font size using javascript

refer http://www.lifegoeson.in

with little r & d I found that <span style="font-size: small">
causes this issue
the text is cut and pasted from word
and edited using fckeditor

please help
[code]

function superhtmlentities($text) {
$entities = array(128 => 'euro', 130 => 'sbquo', 131 => 'fnof', 132 => 'bdquo', 133 => 'hellip', 134 => 'dagger', 135 => 'Dagger', 136 => 'circ', 137 => 'permil', 138 => 'Scaron', 139 => 'lsaquo', 140 => 'OElig', 145 => 'lsquo', 146 => 'rsquo', 147 => 'ldquo', 148 => 'rdquo', 149 => 'bull', 150 => '#45', 151 => 'mdash', 152 => 'tilde', 153 => 'trade', 154 => 'scaron', 155 => 'rsaquo', 156 => 'oelig', 159 => 'Yuml');
$new_text = '';
for($i = 0; $i < strlen($text); $i++) {
$num = ord($text{$i});
if (array_key_exists($num, $entities)) {
switch ($num) {
case 150:
$new_text .= '-';
break;
default:
$new_text .= '&'.$entities[$num].';';
}
}
else
if($num < 127 || $num > 159) {
$new_text .= htmlentities($text{$i});
}
}
return $new_text;
}




Similar Threads
Thread Thread Starter Forum Replies Last Post
Special Characters not working for me Russ XSLT 1 June 18th, 2008 05:21 PM
Custom script to remove special characters midoriweb Classic ASP Basics 2 January 12th, 2007 08:05 AM
storing special special characters in nvarchar... ACE2084 SQL Server 2000 2 February 9th, 2005 11:45 AM
special characters lian_a Classic ASP Basics 3 June 23rd, 2004 05:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.