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);

	}