【问题标题】:Convert Windows-1256 to UTF-8将 Windows-1256 转换为 UTF-8
【发布时间】:2012-05-21 11:23:26
【问题描述】:

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

现在我想将此数据插入 MySQL 数据库,字符集为 utf8_general_ci。

有什么办法吗?

【问题讨论】:

标签: php utf-8 encode windows-1255


【解决方案1】:

你需要iconv():

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

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

如果您想要一个 100% 安全、无处不在的方式来做到这一点,最简单的做法是使用查找表 str_replace()

【讨论】:

    猜你喜欢
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 1970-01-01
    • 2013-10-10
    相关资源
    最近更新 更多