1

我通过 curl 获取网页的内容,字符集设置为 Windows-1256。

现在我想用 charset utf8_general_ci 将此数据插入 MySQL 数据库。

有没有办法做到这一点?

4

1 回答 1

4

你需要iconv()

$utf8 = iconv('windows-1256', 'utf-8', $win1256);

...虽然Supported character sets depend on the iconv implementation of your system.,所以 YMMV。

如果你想要一个 100% 安全的、随处可用的方法来做到这一点,最简单的做法就是使用查找表str_replace()

于 2012-05-21T11:26:50.407 回答