dqeznd1697 2016-02-16 12:09
浏览 76
已采纳

带有ascii图标的文本的Mysql列类型

i have a textarea witch user can insert ascii characters(icon mostly) in it, when i try to insert it into my table :

with utf8_general_ci or utf8_unicode_ci every thing after the first ascii icon is removed and i am left with whatever text that was before the icon

with utf8mb4_general_ci andutf8mb4_unicode_ci all the ascii icons are converted to ?

so whats the best column type to save text with ascii icons in it ? do i need to escape them before inserting ? how ?

here is a sample of the text:

  • 写回答

1条回答 默认 最新

  • duanpa1898 2016-02-16 12:27
    关注

    OK, found the answer my self, i had to set the connections character sets to utf8mb4 too, with the utf8mb4_unicode_ci column.

    'db'            => [
        'driver'         => 'Pdo_Mysql',
        'database'       => 'telegram',
        'hostname'       => 'localhost',
        'driver_options' => [
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8mb4\'',
        ],
        'username'       => 'root',
        'password'       => '',
    ],
    

    And of course the client and server too

    [client]
    default-character-set = utf8mb4
    
    [mysql]
    default-character-set = utf8mb4
    
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
    

    source : https://mathiasbynens.be/notes/mysql-utf8mb4

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程