Language (char set?) issue

St_Aug_Beach_Bum
St_Aug_Beach_Bum used Ask the Experts™
on
I'm doing this:

$wiki_url = 'http://en.wikipedia.org/wiki/Main_Page';
$content_raw = file_get_contents($wiki_url);

and then I strip down to the content I need, which includes removing the meta/header/html.

After doing that, some of the text is in strange characters, like " coup d'état ' instead of " coup d'état ".

What am I dealing with here, and how can I convert the string so it's in english characters, ie: " coup d'etat "

Thanks,  Chris
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Use a function called
utf8_encode($string)
Top Expert 2008
Commented:
Wikipedia use utf8, your page is probably using iso-8859-1. I think you need the opposite function from what mallcore suggests: utf8_decode($string).

Author

Commented:
Yes!  Tried them both, this worked, thank you both for your suggestions.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Commented:
Darn. Missed the follow-up opportunity. :) Oh well. cxr basically said what I was trying to explain in the last question you asked.

Author

Commented:
Heh, well, if you do javascript as well, I've got another challenge at:

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_24580248.html

Another one of my 'almost there, but not quite working right' projects I'm trying to work on today :)

I don't see js on your profile though...

Commented:
Hmm,  guess I forgot about JS when I was tweaking my profile the other day. I can do JS. :) Hope I answered your JS question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial