Different Encoding rss feed & web site PROBLEM !?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
soulmasta
Forum Newbie
Posts: 17
Joined: Fri Aug 15, 2008 4:50 pm

Different Encoding rss feed & web site PROBLEM !?

Post by soulmasta »

Hello all,

i would like to ask ,

when we parse an xml rss feed and we are taking some data (par example: actual weather, news headlines etc etc) for our web site and the rss feed's encoding is ISO or windows, but, our web site's encoding is UTF-8 ..what we can do on this point to make the data that we are getting from the feed visible on our website ?

Cause when the feed's encoding is ISO or windows and our site's encoding is UTF-8 the data that we want to appear on our website will not appear correctly !

How we can solve problem such as this one ?

please help ..am waiting for your answers ;)
soulmasta
Forum Newbie
Posts: 17
Joined: Fri Aug 15, 2008 4:50 pm

Re: Different Encoding rss feed & web site PROBLEM !?

Post by soulmasta »

in otherwords,

how we can convert the encoding type of our rss feed, so that will be the same encoding type with our page's encoding type ?

How we can convert our windows or ISO rss feed to UTF-8 ..????

:roll:
dml
Forum Contributor
Posts: 133
Joined: Sat Jan 26, 2008 2:20 pm

Re: Different Encoding rss feed & web site PROBLEM !?

Post by dml »

Have you tried using iconv?
André D
Forum Commoner
Posts: 55
Joined: Thu Aug 28, 2008 7:03 pm

Re: Different Encoding rss feed & web site PROBLEM !?

Post by André D »

Like dml said, iconv() is the PHP function to use to convert a string from one character encoding to another.

I've done some tests with iconv('ISO-8859-1', 'UTF-8', ...) and have found the results to be imperfect. There were some characters in the input ISO-8859-1 string that did not get converted, even though UTF-8 supports them. I'm not sure, but it might be a problem with the character collations in my locale. I'll post the results of my test on here when I have more time.
André D
Forum Commoner
Posts: 55
Joined: Thu Aug 28, 2008 7:03 pm

Re: Different Encoding rss feed & web site PROBLEM !?

Post by André D »

If your source string is always encoded as ISO-8859-1 you should use utf8-encode() instead of iconv() to perform the conversion to UTF-8.
Post Reply