PHP Convert Windows-1251 to UTF 8

前端 未结 5 665
粉色の甜心
粉色の甜心 2021-01-04 10:03

I have a small html code and I need to convert it to UTF-8.
I use this iconv(\"windows-1251\", \"utf-8\", $html);

All text converts correctly, but

5条回答
  •  Happy的楠姐
    2021-01-04 10:53

    I always use manual convertation (character-by-character), like this:

    $input= 'Обращение РљР°С';
    
    
    
    $s= str_replace('С?','fgr43443443',$input);
    $s= mb_convert_encoding($s, "windows-1251", "utf-8");
    $s= str_replace('fgr43443443','ш',$s);
    
    
    echo $s;
    

    p.s. dont forget, the .php file encoding should be UTF8. also, in the head of HTML,insert standard declaration for UTF8

    
    

提交回复
热议问题