Convert encoding?

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
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Convert encoding?

Post by divito »

I'm dealing with MagpieRSS and feeds that I'm trying to parse are encoded with Windows-1252. MagpieRSS can't deal with this encoding and I'm stuck being unable to use the feeds from this one site.

I was wondering what the easiest way to fix this problem might be. Would I go about converting the feeds in question to send to Magpie, and how would that be accomplished? Or might it be easier to alter the Magpie parsing file to deal with it?

Any push in the right direction is greatly appreciated. Hoping this can be remedied in an easier way instead of redoing all my scripts with another parser. :(
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Convert encoding?

Post by Eran »

Try using iconv, it covers windows-1252 - only there it's called cp1252.

Code: Select all

$text = iconv('cp1252','utf-8//IGNORE',$text);
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: Convert encoding?

Post by divito »

Magpie has iconv in it already, but it apparently only deals with the easier encodings. I'm not sure how I'd use your suggestion to put it back into a url, as it seems Magpie doesn't do it any other way. I suppose another option that might work is saving it as a file each time and reading it. Though that will take more research for me to learn.

If only it was as simple as having Magpie ignore the first line where it says the encoding. Of course I had to pick a parser that hasn't been updated in eons.
Post Reply