dongxiao3694 2014-11-07 10:06
浏览 16
已采纳

如何更改Simple HTML DOM检索的网页的编码?

I am trying to read contents of a web page

$html = file_get_html('http://www.example.com/somepage.aspx');

Since the page's encoding is Windows-1254, and I work on a page encoded as UTF-8, I cannot replace some words which have language-specific characters.

For Example:

If I try to

$str2 = str_replace('TÜRKÇE', 'TURKCE', $str);

it does not replace.

I have tried htmlentities() function, It worked but deleted some words which contains special characters.

  • 写回答

2条回答 默认 最新

  • dsirr48088 2014-11-10 05:34
    关注

    After getting strings I have used iconv('Windows-1254', 'utf-8', $str) function (thanks to @pguardiario). This solved my problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部