PHP convert Win-1251 to UTF-8
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.
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
Fixed it, turns out it wasn't cp1252, but cp1251!
精彩评论