[TYPO3-dev] t3lib_div:xml2array() and PHP 4.4.x
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Fri Sep 8 10:29:51 CEST 2006
Martin Kutschker schrieb:
> Martin Kutschker schrieb:
>
>> Hi!
>>
>> The code has a switch for PHP 5.x to use the
>> XML_OPTION_TARGET_ENCODING option.
>>
>> While devolping an extension it occured to me that this is also
>> necessary for PHP 4.4.0.
>>
>> Can anybody confirm this? It's not mentioned in the PHP docs, but
>> setting the option makes my code work ;-)
>
>
> Aha! New infos:
>
> My editor on Windows adds byte order mark (BOM) at the beginning of the
> file. It adds the correct sequence EF BB BF to signify UTF-8.
>
> But this affects how the data is treated by PHP on Linux. If I remove
> the BOM everyting is fine otherwise I get garbled data unless I set the
> target encoding.
>
> As a BOM is a Unicode feature and I doesn't have always the choice of
> input methods I think that TYPO3 should handle such a case consitently
> across PHP platforms (version and OS). Therefore I suggest to look for
> the BOM and if a UTF-8 BOM is found to set XML_OPTION_TARGET_ENCODING.
The fix is:
if (substr($string,0,3)=="\xEF\xBB\xBF") {
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
} elseif ((double)phpversion()>=5) {
...
}
Masi
More information about the TYPO3-dev
mailing list