Location: PHPKode > projects > Laikwan WMC > wmc_20070325/wmcLib/clean.php
<?


function wmcClean_cleanData_IGNORE($contents){	

	// clean up smart quotes
	// see http://shiflett.org/archive/165
    $search = array(
		chr(145),
		chr(146),
		chr(96),
		chr(147),
		chr(148),
		chr(151),
		chr(150),
		chr(133)
		);
	$replace = array(
		'&lsquo;', /* ' */
		'&rsquo;', /* ' */
		"'",
		'&ldquo;', /* " */
		'&rdquo;', /* " */
		'&mdash;', /* --- */
		'&ndash;', /* -- */
		'&#8230;' /* ... */
		); 
	$contents = str_replace($search, $replace, $contents);  

	//$contents = strip_tags($contents);
}

function wmcClean_cleanData($contents){	
	$contents = htmlentities($contents);

    $search		= array('&quot;', "'", "&lt;", "&gt;", "&amp;");
	$replace	= array('"', "'", "<", ">", "&"); 
	$contents = str_replace($search, $replace, $contents); 
/*	$contents = ereg_replace("&lt;", "<", $contents);	 
	$contents = ereg_replace("&gt;", ">", $contents);	 
	$contents = ereg_replace("&amp;", "&", $contents);	 // must be at end*/
	return $contents ;
}


function wmcClean_cleanDataForXmlElt($contents){
	$contents = wmcClean_cleanData($contents);
	$contents = ereg_replace("]]>", "]]&gt;", $contents);	 
	return "<![CDATA[" . $contents . "]]>";
}

function wmcClean_noHtmlForXmlElt($contents){
	$contents = htmlentities($contents);
	return "<![CDATA[" . $contents  . "]]>"; // to escape at least ampersand :(
}


?>
Return current item: Laikwan WMC