Afficher un message
Vieux 16/09/2007, 02h48   #2
macca
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Stripping MS Word code from my forms once and for all.

I found this on php.net at http://uk2.php.net/strtr which may be of
some :




After battling with strtr trying to strip out MS word formatting from
things pasted into forms I ended up coming up with this..

it strips ALL non-standard ascii characters, preserving html codes and
such, but gets rid of all the characters that refuse to show in
firefox.

If you look at this page in firefox you will see a ton of "question
mark" characters and so it is not possible to copy and paste those to
remove them from strings.. (this fixes that issue nicely, though I
admit it could be done a bit better)

<?
function fixoutput($str){
$good[] = 9; #tab
$good[] = 10; #nl
$good[] = 13; #cr
for($a=32;$a<127;$a++){
$good[] = $a;
}
$len = strlen($str);
for($b=0;$b < $len+1; $b++){
if(in_array(ord($str[$b]), $good)){
$newstr .= $str[$b];
}//fi
}//rof
return $newstr;
}
?>

  Réponse avec citation
 
Page generated in 0,04947 seconds with 9 queries