tags:

views:

30

answers:

2

I'm fetching the contents of a Windows-1251 encoded web site using file_get_html and want to serve it as UTF-8.

I set the headers to UTF-8 using: header('Content-type: text/html; charset=UTF-8');

Then i output the data using iconv("cp1252","UTF-8",'"desc":"'.$desc);

The output is no longer strange questions marks, but it's still not Cyrillic.

What am i doing wrong?

+1  A: 

Try not prepending anything to your string, letting it be just

iconv("cp1252","UTF-8",$desc);

By the way, do you get the cyrillic output if you just do

header('Content-Type: text/html; charset=cp1252');
echo $desc; // No iconv
ssice
Yes I do, however my web application is UTF-8 so i have to use UTF8.
@user117701 ok, I have just read your answer. It seems you just misspelled your charset
ssice
+1  A: 

Fixed it, turns out it wasnt cp1252, but cp1251!

You should accept this answer then.
You