【问题标题】:How can I convert latin1 data to UTF8 on mysql insert or update?如何在 mysql 插入或更新时将 latin1 数据转换为 UTF8?
【发布时间】:2012-03-22 15:52:47
【问题描述】:

我每晚从一个以拉丁文存储字段的网络服务获取数据,但我的数据库是 utf8 格式。 更新或插入记录时是否可以将数据字符串转换为utf8?

【问题讨论】:

    标签: php mysql unicode encoding


    【解决方案1】:
    $output = utf8_encode ( $inputstring );
    

    阅读更多关于utf8_encode

    【讨论】:

      【解决方案2】:

      看看 PHP 中的多字节字符串函数提供的功能。具体来说,我认为mb_convert_encoding 是您正在寻找的功能。

      $output = mb_convert_encoding ($input, 'UTF-8', 'ISO-8859-1');
      

      根据Wikipedia,ISO-8859-1 是“Latin-1”的官方编码标准。

      【讨论】:

        猜你喜欢
        • 2010-11-29
        • 1970-01-01
        • 2011-05-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-05
        • 2020-01-26
        • 2015-05-20
        相关资源
        最近更新 更多