core-bundle/src/Resources/contao/library/Contao/StringUtil.php
public static function specialchars($strString, $blnStripInsertTags=false, $blnDoubleEncode=false)
	{
		if ($blnStripInsertTags)
		{
			$strString = static::stripInsertTags($strString);
		}

		// Use ENT_COMPAT here (see #4889)
		return htmlspecialchars($strString, ENT_COMPAT, Config::get('characterSet'), $blnDoubleEncode);
	}
public static function specialchars($strString, $blnStripInsertTags=false, $blnDoubleEncode=false)
	{
		if ($blnStripInsertTags)
		{
			$strString = static::stripInsertTags($strString);
		}

		// Use ENT_COMPAT here (see #4889)
		return htmlspecialchars($strString, ENT_COMPAT, Config::get('characterSet'), $blnDoubleEncode);
	}
Convert special characters to HTML entities preventing double conversions

@param string  $strString          The input string
@param boolean $blnStripInsertTags True to strip insert tags
@param boolean $blnDoubleEncode    True to encode existing html entities

@return string The converted string