views:

30

answers:

1

I am using the Amazon and eBay API via PHP5 and Curl to get product listings for a client. When I ask the API to give me a description or a category for a product, I'm sometimes getting something that looks like this:

Estée Lauder

When I go look at the XML download from the API, it shows this entry inside:

<categoryName>Estée Lauder</categoryName>

The product in particular was this one.... So as not to give away the affiliate ID, just do this -- query http://ebay.com/ on "ESTEE LAUDER HIGH GLOSS ULTRA BRILLIANCE GLOSS-'Berry'". Then click the link that is named this.

How can I trap for this and properly display this? I am using PHP5.

+1  A: 

Use the mb_content_encoding function and convert the string utf-8. You can read more from this http://hu.php.net/manual/en/book.mbstring.php

turbod
What percentage of shared hosting plans would you say now have this loaded into their PHP5?
Volomike
I think all. See the phpinfo() function.
turbod
I ended up using function_exists('mb_convert_encoding') test and then encoding from ISO-8559-1 to UTF-8, and then UTF8 to UTF-8. The latter is a trick that seems to strip out stuff that didn't get fixed in the first encoding step. It's not perfect, but it works fairly well.
Volomike