--- class.t3lib_div.php 2009-02-10 09:36:26.000000000 +0100 +++ class.t3lib_div.php.new 2009-06-25 13:41:48.000000000 +0200 @@ -2343,12 +2343,19 @@ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); // default output charset is UTF-8, only ASCII, ISO-8859-1 and UTF-8 are supported!!! $match = array(); - preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$match); - $theCharset = $match[1] ? $match[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1'); + // Check for UTF-8 BOM + if(substr($string, 0,3) == chr(0xEF).chr(0xBB).chr(0xBF)) { + $string = substr($string, 3); + $theCharset = 'utf-8'; + } + else { + preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$match); + $theCharset = $match[1] ? $match[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1'); + } xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1 // Parse content: xml_parse_into_struct($parser, $string, $vals, $index);