Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding issues related to simplexml_load_string #60

Closed
taylankasap opened this issue Jul 1, 2016 · 1 comment
Closed

Encoding issues related to simplexml_load_string #60

taylankasap opened this issue Jul 1, 2016 · 1 comment
Labels

Comments

@taylankasap
Copy link

taylankasap commented Jul 1, 2016

simplexml_load_string in AbstractXmlOutputParser:transformXmlToArray method doesn't work for some files based on the encoding/charset.

Sample error (it says warning but it basically is an error since it makes the code not work at all):

Warning: simplexml_load_string(): Entity: line 54: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xFC 0x73 0x6E 0xFC in /Users/taylankasap/Sites/T/vendor/mhor/php-mediainfo/src/Parser/AbstractXmlOutputParser.php on line 14

Replacing line 14 with one of these makes it work but I'm not sure if this won't break anything else and work for all encodings. Writing tests for different encodings might be a good idea

// This
$xml = simplexml_load_string(str_replace('encoding="UTF-8"', 'encoding="ISO-8859-1"', $xmlString));
// or this
$xml = simplexml_load_string(utf8_encode($xmlString));

Example code & mp3 file that's not working:

$mediaInfo = new \Mhor\MediaInfo\MediaInfo();
$mediaInfoContainer = $mediaInfo->getInfo("track-7f01c33918c6070efca7851b14bb31a3.mp3");

track-7f01c33918c6070efca7851b14bb31a3.mp3.zip
Bytes 0xFC 0x73 0x6E 0xFC in the warning corresponds to the bold part of the artist name: "Erdal Hüsnü Kizilçay"

@mhor mhor added the bug label Jul 1, 2016
@mhor
Copy link
Owner

mhor commented Jul 1, 2016

@taylankasap thanks for your feedback I will try to solve this soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants