NYCPHP Meetup

NYPHP.org

[nycphp-talk] Encoding help?

David Krings ramons at gmx.net
Thu Feb 22 06:34:09 EST 2007


Joseph Crawford wrote:
> Guys i am trying to consume the Google maps API and when i pass it an 
> address in Montreal QC i get the follwoing error
> 
> *Warning*: SimpleXMLElement::__construct() [ 
> function.SimpleXMLElement---construct 
> <http://codebowl.homeip.net/eremaps/function.SimpleXMLElement---construct>]: 
> Entity: line 1: parser error : Input is not proper UTF-8, indicate 
> encoding ! Bytes: 0xE9 0x61 0x6C 0x2C in 
> */Applications/MAMP/htdocs/eremaps/import.php* on line *41
> 
> *the issue is that Google is returning this in the XML response
> 
> <LocalityName>Montréal</LocalityName>
> 
> I am guessing it is throwing something off with the SimpleXML object?  
> How can i make it handle this?

My guess is that it chokes on the accented character. It expects it as 
UTF-8 (it complained about it notbeing proper), so who knows what an é 
ends up to be.
I recommend trying an address that does not produce any accented 
characters or Umlaute or whatever else. That way you can test if your 
code is generally OK and isolate the problem to some incompatible 
character encoding.


David



More information about the talk mailing list