All pastes #401896 Raw Edit

Mine

public php v1 · immutable
·published 2007-03-19 16:20 UTC
rendered paste body
//-------------------------------------------------------------// This is a generic function for description text to remove// MS Word high ASCII// and escape dodgy charaters before adding to the database:// Usage:  $clean_description = crapKiller($description_field)function crapKiller($body){	$trans_tbl = array() ;		$trans_tbl[chr(11)] = "\n"; // some sort of new line character		$trans_tbl[chr(34)] = '&#34;' ;	// 	quote	$trans_tbl[chr(38)] = '&#38;' ;	// 	ampersand	$trans_tbl[chr(60)] = '&#60;' ;	// 	less-than	$trans_tbl[chr(62)] = '&#62;' ;	// 	more-than	$trans_tbl[chr(128)] = '&#8364;' ;	// 	euro	$trans_tbl[chr(129)] = '&#8364;' ; 	//	euro	$trans_tbl[chr(130)] = '&#8218;' ; 	//	low quote	$trans_tbl[chr(131)] = '&#402;' ; 	//	florin	$trans_tbl[chr(132)] = '&#8222;' ; 	// 	double low quote	$trans_tbl[chr(133)] = '&#8230;' ; 	//	ellipsis	$trans_tbl[chr(134)] = '&#8224;' ;	//	dagger	$trans_tbl[chr(135)] = '&#8225;' ; 	//	double dagger	$trans_tbl[chr(136)] = '&#710;' ; 	//	circumflex	$trans_tbl[chr(137)] = '&#8240;' ; 	//	per thousand	$trans_tbl[chr(138)] = '&#352;' ; 	//	S caron	$trans_tbl[chr(139)] = '&#8249;' ; 	//	left angle quote	$trans_tbl[chr(140)] = '&#338;' ; 	//	OE ligature	$trans_tbl[chr(142)] = '&#381;' ; 	//	Z caron	$trans_tbl[chr(145)] = '&#8216;' ; 	//	left single quote	$trans_tbl[chr(146)] = '&#8217;' ; 	//	right single quote	$trans_tbl[chr(147)] = '&#8220;' ; 	//	left double quote	$trans_tbl[chr(148)] = '&#8221;' ; 	//	right double quote	$trans_tbl[chr(149)] = '&#8226;' ; 	//	bullet	$trans_tbl[chr(150)] = '&#8211;' ; 	//	en dash	$trans_tbl[chr(151)] = '&#8212;' ; 	//	em dash	$trans_tbl[chr(152)] = '&#732;' ; 	//	small tilde	$trans_tbl[chr(153)] = '&#8482;' ; 	//	trademark	$trans_tbl[chr(154)] = '&#353;' ; 	//	small s caron	$trans_tbl[chr(155)] = '&#8250;' ; 	//	right angle quote	$trans_tbl[chr(156)] = '&#339;' ; 	//	oe ligature	$trans_tbl[chr(158)] = '&#382;' ; 	// 	small z caron	$trans_tbl[chr(159)] = '&#376;' ; 	//	Y with diaeresis	for ( $i=160; $i<=255; $i++ ) {		$trans_tbl[chr($i)] = '&#' . $i . ';' ;	}	//$trans_tbl[chr(8216)] = "'" ; 	//	single smart quote left	//$trans_tbl[chr(8217)] = "'" ; 	//	single smart quote right		$to_return = strtr ( $body , $trans_tbl );		//$to_return = str_replace('&#65533;', "'", $to_return);		return  $to_return;	}