static function EncodeSpecialCharacters($string, $escapeQuotes = true, $numericEncodingOnly = true, $replaceSmartQuotes = false)
	{
		if (strlen($string) == 0) return "";

		$result = $string;

		// do this first before encoding
		if ($replaceSmartQuotes) $result = self::ReplaceSmartQuotes($result);

		// this method does not double-encode, but replaces single-quote with a numeric entity
		if ($escapeQuotes) $result = htmlspecialchars($result, ENT_QUOTES, null, false);

		// this method double-encodes values but uses the special character entity for single quotes
		// if ($escapeQuotes) $result = self::ReplaceXMLSpecialChars($result);

		// for special chars we don't need to insist on numeric encoding only
		return self::EncodeToHTML($result,$numericEncodingOnly);

	}
static function EncodeSpecialCharacters($string, $escapeQuotes = true, $numericEncodingOnly = true, $replaceSmartQuotes = false)
	{
		if (strlen($string) == 0) return "";

		$result = $string;

		// do this first before encoding
		if ($replaceSmartQuotes) $result = self::ReplaceSmartQuotes($result);

		// this method does not double-encode, but replaces single-quote with a numeric entity
		if ($escapeQuotes) $result = htmlspecialchars($result, ENT_QUOTES, null, false);

		// this method double-encodes values but uses the special character entity for single quotes
		// if ($escapeQuotes) $result = self::ReplaceXMLSpecialChars($result);

		// for special chars we don't need to insist on numeric encoding only
		return self::EncodeToHTML($result,$numericEncodingOnly);

	}
static function EncodeSpecialCharacters ( $ string , $ escapeQuotes = true , $ numericEncodingOnly = true , $ replaceSmartQuotes = false ) { if ( strlen ( $ string ) == 0 ) return "" ; $ result = $ string ; // do this first before encoding if ( $ replaceSmartQuotes ) $ result = self :: ReplaceSmartQuotes ( $ result ) ; // this method does not double-encode, but replaces single-quote with a numeric entity if ( $ escapeQuotes ) $ result = htmlspecialchars ( $ result , ENT_QUOTES , null , false ) ; // this method double-encodes values but uses the special character entity for single quotes // if ($escapeQuotes) $result = self::ReplaceXMLSpecialChars($result); // for special chars we don't need to insist on numeric encoding only return self :: EncodeToHTML ( $ result , $ numericEncodingOnly ) ; }
This HTML encodes special characters and returns an ascii safe version.
This function extends EncodeToHTML to additionally strip
out characters that may be disruptive when used in HTML or XML data

@param string value to parse
@param bool $escapeQuotes true to additionally escape ENT_QUOTE characters <>&"' (default = true)
@param bool $numericEncodingOnly set to true to only use numeric html encoding.  warning, setting to false may be slower performance (default true)
@param bool $replaceSmartQuotes true to replace "smart quotes" with standard ascii ones, can be useful for stripping out windows-only codes (default = false)
@return string
This HTML encodes special characters and returns an ascii safe version . This function extends EncodeToHTML to additionally strip out characters that may be disruptive when used in HTML or XML data