mysql表情符号_在MySQL中搜索表情符号

bd96500e110b49cbb3cd949968f18be7.png

I have a string that looks like this:

rmeIj.png

Now, when my app shoves this string into its utf8 mysql database column, it looks like this in the MySQL CLI:

yLmWv.png

If I select convert(mystring using utfmb4) it still looks like this.

And if I turn it to hex using select hex(mystring) from mytable;, it looks like this:

C3A2CB9CE282ACC3AFC2B8C28FC3B0C5B8C592CB86C3B0C5B8C592C5A0C3B0C5B8C592C281C3B0C5B8E280A1C2ACC3B0C5B8E280A1C2A7

Now, let's say I want to find strings with that emoji wave in it. Well, the hex for the wave emoji is F09F8C8A. But F09F8C8A isn't in the hex above so something like select * from mytable where hex(mystring) like '%F09F8C8A%'; doesn't work.

Any suggestions?

解决方案

I call that "double encoding". Your client claimed it was getting latin1 characters, but told MySQL that they should be utf8, so a 3-byte utf8 character got converted to 6 bytes in the database.

You need to fix both the client and the data in the table(s). This link discusses it: http://mysql.rjweb.org/doc.php/charcoll . (Sorry, there is no brief summary of how to fix your problems.) The issues and the fixes.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值