How to load XML when PHP can't indicate the right encoding?

前端 未结 4 1614
梦谈多话
梦谈多话 2020-12-12 00:08

I\'m trying to load an XML source from a remote location, so i have no control of the formatting. Unfortunately the XML file I\'m trying to load has no encoding:

<         


        
4条回答
  •  青春惊慌失措
    2020-12-12 01:09

    I ran in to a similar situation. I was getting an XML file that was supposed to be UTF-8 encoded, but it included some bad ISO characters.

    I wrote the following code to encode the bad characters to UTF-8

    load($filename);
    
    ?>
    

    I posted about the solution in more detail at: http://dev.strategystar.net/2012/01/convert-bad-characters-to-utf-8-in-an-xml-file-with-php/

提交回复
热议问题