mysql中存储emoji表情

在做移动应用时,会遇到ios或者android用户会在文本的区域输入emoji表情(如:??),如果不做一定处理,就会导致插入数据库异常。如下:

Incorrect string value: '\xF0\x9F\x99\x82" ...' for column 'Source'

这是因为emoji表情符号为4个字节的字符,而 utf8 字符集只支持1-3个字节的字符,导致无法写入数据库。

解决方案:

1.修改数据库的字符集为utf8mb4。(注意:mysql版本需要5.5.3以上)具体是需要修改整个mysql库、表或者具体字段字符集自己决定。当然,修改完数据库字符集后还没有大功告成。需要看下程序里连接数据库的时候有没有指定字符集为utf8mb4。php中PDO连接方式如下:

$db = new pdo('mysql:host=127.0.0.1;port=3306;dbname=mysql;charset=utf8mb4','user','password');

2.如果不想修改数据库字符集或者版本比较低不支持,那就只能存的时候转义一下了。可以转为base64格式或者其他支持的转义方式。

 

225 Responses

  1. Good day! This is my first comment here so I just wanted to give a quick
    shout out and tell you I genuinely enjoy reading through
    your posts. Can you recommend any other blogs/websites/forums that cover the same
    subjects? Thank you so much!

  2. Hello! Quick question that’s entirely off topic. Do you know how to make your
    site mobile friendly? My blog looks weird when viewing
    from my iphone. I’m trying to find a theme or plugin that might be able to correct this problem.
    If you have any recommendations, please share. Thank you!

  3. Hi! I know this is kinda off topic however , I’d figured I’d
    ask. Would you be interested in trading links or maybe
    guest writing a blog post or vice-versa? My site discusses a lot of the same topics as yours
    and I believe we could greatly benefit from each other.
    If you are interested feel free to send me an email. I look
    forward to hearing from you! Awesome blog by the way!

  4. Right here is the perfect site for anybody who would like to
    understand this topic. You know so much its almost tough to argue with
    you (not that I actually will need to…HaHa). You certainly put a new spin on a topic which has been discussed for decades.
    Wonderful stuff, just great!

  5. I’ll right away seize your rss as I can’t to find your email subscription hyperlink or newsletter service.
    Do you’ve any? Kindly permit me recognise so that I may
    just subscribe. Thanks.

  6. You are so awesome! I don’t think I have read through something like that before.

    So good to find someone with a few genuine
    thoughts on this topic. Seriously.. thank you for starting this up.

    This web site is something that is required on the internet,
    someone with a bit of originality!

  7. Howdy! Do you use Twitter? I’d like to follow you if that
    would be okay. I’m definitely enjoying your blog and look forward to
    new posts.

  8. Link exchange is nothing else however it is just placing the other person’s blog link on your page at suitable place and other person will also do similar in favor
    of you.

  9. Howdy! This is my first visit to your blog! We are a group of volunteers and starting a new project
    in a community in the same niche. Your blog provided us useful
    information to work on. You have done a wonderful job!

  10. Woah! I’m really enjoying the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between user
    friendliness and appearance. I must say you have done a great job with this.
    In addition, the blog loads very fast for me on Chrome.

    Exceptional Blog!

  11. Attractive section of content. I just stumbled upon your weblog and in accession capital
    to assert that I acquire actually enjoyed account your blog posts.

    Any way I’ll be subscribing to your feeds and even I achievement you access consistently rapidly.

  12. Does your website have a contact page? I’m
    having a tough time locating it but, I’d like to send you an email.
    I’ve got some recommendations for your blog you might
    be interested in hearing. Either way, great site and I look forward to seeing it improve over time.

  13. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time
    a comment is added I get four emails with the same comment.
    Is there any way you can remove me from that service? Many thanks!

  14. Hey there! I simply wish to offer you a huge thumbs up for your great info you have got right here on this post.
    I am coming back to your website for more soon.

  15. First off I want to say superb blog! I had a quick question which I’d like to ask if you don’t mind.

    I was curious to know how you center yourself and
    clear your mind before writing. I’ve had trouble
    clearing my thoughts in getting my ideas out. I
    do take pleasure in writing however it just seems like the first 10 to 15 minutes are wasted just trying to figure out how to
    begin. Any suggestions or hints? Kudos!

  16. Greetings from Carolina! I’m bored at work so I decided to check out your website on my iphone during lunch break.
    I really like the info you provide here and can’t wait to
    take a look when I get home. I’m surprised at how quick your blog loaded on my cell
    phone .. I’m not even using WIFI, just 3G ..
    Anyways, amazing blog!

  17. I don’t even know how I ended up here, but I thought
    this post was good. I don’t know who you are but certainly
    you are going to a famous blogger if you aren’t already
    😉 Cheers!

  18. Hello! I’ve been reading your blog for some time now and finally got the bravery to go ahead
    and give you a shout out from Kingwood Tx! Just wanted to tell you keep up the excellent job!

  19. Your way of telling the whole thing in this post is truly good, all can without difficulty know it, Thanks a lot.

  20. Hi there, I wish for to subscribe for this weblog to obtain most recent updates, thus where can i do it please help out.

  21. You’re so interesting! I don’t believe I’ve read through a single thing like that before.
    So nice to find another person with genuine thoughts on this
    issue. Seriously.. thanks for starting this up. This web site is something that’s needed on the internet, someone with a little originality!

  22. Hi friends, pleasant piece of writing and nice arguments commented at
    this place, I am actually enjoying by these.

  23. My spouse and I stumbled over here coming from a different
    web page and thought I might check things out. I like what
    I see so now i’m following you. Look forward to looking into your
    web page again.

  24. What’s up colleagues, its wonderful paragraph on the topic of tutoringand
    entirely defined, keep it up all the time.

  25. Genuinely when someone doesn’t be aware of after that its up to other viewers
    that they will help, so here it occurs.

  26. After I initially left a comment I seem to have clicked on the -Notify me when new comments are added-
    checkbox and from now on whenever a comment is added I recieve four emails with the same comment.
    There has to be a means you can remove me from that service?
    Thanks!

  27. I loved as much as you will receive carried
    out right here. The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an shakiness over
    that you wish be delivering the following. unwell unquestionably come further
    formerly again as exactly the same nearly very often inside
    case you shield this hike.

  28. I’m really loving the theme/design of your blog. Do you ever run into any internet browser compatibility issues?

    A number of my blog audience have complained about my site not working correctly in Explorer but looks great in Safari.

    Do you have any advice to help fix this problem?

  29. I think what you posted made a ton of sense.
    But, what about this? suppose you were to write a killer headline?

    I mean, I don’t wish to tell you how to run your blog, but what if you added something that makes people
    desire more? I mean mysql中存储emoji表情 |
    Lyy's blog is kinda plain. You could glance at Yahoo’s home
    page and see how they create news titles to get people to click.
    You might add a related video or a pic or two to grab people interested about everything’ve got to say.
    Just my opinion, it would make your website a
    little livelier.

  30. I do not know whether it’s just me or if everyone
    else encountering issues with your site. It looks like some of
    the text on your content are running off the screen. Can somebody else please provide feedback and let me know if this is happening to them as well?
    This might be a issue with my web browser because I’ve had this happen previously.
    Cheers

  31. Hello superb website! Does running a blog such as
    this require a massive amount work? I have very little
    knowledge of programming however I was hoping to start my own blog soon. Anyways, if
    you have any ideas or tips for new blog owners please share.
    I know this is off subject but I simply had to ask. Many thanks!

  32. A motivating discussion is definitely worth comment.
    I believe that you should publish more about this subject matter,
    it might not be a taboo subject but typically people don’t discuss these issues.
    To the next! Cheers!!

  33. Howdy! I know this is kinda off topic but I was wondering which blog platform are you using
    for this website? I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a
    good platform.

  34. Howdy very cool website!! Guy .. Beautiful .. Wonderful ..
    I will bookmark your site and take the feeds also? I’m satisfied to seek out so many useful info
    right here in the publish, we’d like work out more strategies
    on this regard, thanks for sharing. . . . .

    .

  35. Undeniably believe that which you stated. Your favourite justification appeared
    to be at the web the simplest thing to keep in mind of.
    I say to you, I definitely get irked whilst people consider concerns that they just don’t
    recognize about. You controlled to hit the nail upon the highest and defined out
    the whole thing with no need side effect , people can take a signal.
    Will likely be again to get more. Thank you

  36. Hi! Do you know if they make any plugins to help with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Thank you!

  37. Hi! I could have sworn I’ve been to this site before but after checking through some of the post I realized it’s new to me.
    Anyways, I’m definitely delighted I found it and I’ll be book-marking and checking back frequently!

  38. Wow that was strange. I just wrote an extremely long comment but after I clicked submit my comment
    didn’t show up. Grrrr… well I’m not writing all that over again. Anyways,
    just wanted to say wonderful blog!

  39. Wonderful goods from you, man. I have understand your
    stuff previous to and you’re just too fantastic. I actually like what you have acquired here,
    certainly like what you’re saying and the way in which you say it.
    You make it entertaining and you still care for to keep it smart.

    I can’t wait to read much more from you.
    This is really a great web site.

  40. You actually make it appear so easy with your presentation however I to find this matter to be actually one thing that I
    believe I would never understand. It seems too complicated and very extensive
    for me. I am looking ahead on your subsequent post, I will try to get the
    cling of it!

  41. I blog frequently and I seriously appreciate your information. Your article has
    truly peaked my interest. I am going to book mark your site and keep checking for new information about once per
    week. I opted in for your RSS feed as well.

  42. Howdy would you mind stating which blog
    platform you’re using? I’m planning to start my own blog in the
    near future but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique.
    P.S Apologies for being off-topic but I had to ask!

  43. Please let me know if you’re looking for a article author for
    your blog. You have some really good posts and I think
    I would be a good asset. If you ever want to take some of the load off,
    I’d love to write some content for your blog in exchange for a link back to
    mine. Please shoot me an email if interested. Many thanks!

  44. Sweet blog! I found it while browsing on Yahoo News.
    Do you have any suggestions on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!
    Cheers

  45. Just desire to say your article is as surprising.

    The clearness to your publish is just spectacular and i
    could assume you are knowledgeable on this subject.
    Well with your permission let me to take hold of your feed to stay updated with impending post.
    Thank you 1,000,000 and please continue the
    rewarding work.

  46. I have been exploring for a bit for any high-quality articles or weblog posts in this kind of house .
    Exploring in Yahoo I at last stumbled upon this site. Studying this information So i’m happy to
    show that I have a very just right uncanny feeling I found out just what
    I needed. I so much definitely will make certain to don?t fail to remember this web site and give it
    a glance regularly.

  47. I’m not sure exactly why but this web site is loading incredibly
    slow for me. Is anyone else having this problem
    or is it a problem on my end? I’ll check back later and see
    if the problem still exists.

  48. We’re a group of volunteers and opening a new scheme in our community.

    Your website provided us with helpful info to work on. You’ve performed an impressive process and our entire neighborhood can be
    grateful to you.

  49. Great post. I was checking constantly this blog and I am impressed!
    Very useful info specially the last part 🙂 I care for such information much.

    I was looking for this particular info for a long time. Thank you and good
    luck.

  50. Hello There. I found your blog using msn. This is a very well written article.
    I’ll be sure to bookmark it and return to read extra of your helpful info.
    Thank you for the post. I will certainly return.

  51. I’m truly enjoying the design and layout of your website.
    It’s a very easy on the eyes which makes it much more pleasant for me
    to come here and visit more often. Did you hire out a designer to create your theme?

    Fantastic work!

  52. Great site you have here but I was wondering if you knew
    of any user discussion forums that cover the same topics
    talked about here? I’d really love to be a part of group where I can get feedback from other experienced individuals that share the same interest.

    If you have any suggestions, please let me know. Kudos!

  53. You could definitely see your skills within the work you write.
    The world hopes for more passionate writers like you who aren’t afraid to
    say how they believe. Always go after your heart.

  54. I like the valuable info you provide in your articles.

    I will bookmark your weblog and check again here frequently.
    I’m quite certain I will learn many new stuff right here!
    Best of luck for the next!

  55. Hello superb website! Does running a blog like this take
    a great deal of work? I’ve very little expertise in computer programming but I had been hoping to start my own blog in the near future.
    Anyhow, should you have any ideas or techniques for new blog owners please share.
    I know this is off topic however I just
    needed to ask. Thank you!

  56. I have read several good stuff here. Certainly worth bookmarking for revisiting.
    I surprise how much attempt you set to create any such great informative site.

  57. An outstanding share! I have just forwarded this onto a
    colleague who was conducting a little homework on this.

    And he actually ordered me breakfast simply because I found it for him…

    lol. So let me reword this…. Thanks for the meal!! But yeah, thanx for spending time to discuss this matter here on your web page.

  58. I’m not that much of a online reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back in the future.

    Cheers

  59. I’m not that much of a internet reader to be honest
    but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back
    in the future. All the best

  60. Wonderful beat ! I would like to apprentice while you amend your web site, how
    can i subscribe for a weblog web site? The account helped me a appropriate deal.

    I were a little bit acquainted of this your broadcast provided brilliant transparent concept

  61. Wonderful beat ! I would like to apprentice while you
    amend your website, how could i subscribe for a blog web site?

    The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear concept

  62. I’m really loving the theme/design of your blog.
    Do you ever run into any browser compatibility issues?
    A couple of my blog audience have complained about my website not working correctly in Explorer but
    looks great in Opera. Do you have any suggestions to help fix this issue?

  63. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet smart so I’m not 100% positive. Any recommendations or
    advice would be greatly appreciated. Thanks

  64. Do you have a spam problem on this blog; I also am a blogger, and I was wanting to know your situation; we have
    developed some nice methods and we are looking to exchange
    solutions with other folks, be sure to shoot me an email if
    interested.

  65. It is perfect time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I wish to suggest you few interesting things or tips.
    Maybe you can write next articles referring to this article.
    I desire to read more things about it!

  66. Wow that was strange. I just wrote an extremely long comment but after I clicked submit my comment didn’t show
    up. Grrrr… well I’m not writing all that over again. Anyhow, just wanted to say fantastic blog!

  67. I like the valuable information you provide in your articles.
    I’ll bookmark your weblog and check again here frequently.
    I am quite certain I’ll learn lots of new stuff right here!

    Good luck for the next!

  68. Appreciating the time and energy you put into your blog and detailed information you present.
    It’s good to come across a blog every once in a while that isn’t the same old rehashed material.
    Great read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.

  69. I was wondering if you ever considered changing the page layout
    of your site? Its very well written; I love what youve
    got to say. But maybe you could a little more in the
    way of content so people could connect with it better.
    Youve got an awful lot of text for only having
    one or two pictures. Maybe you could space it out better?

  70. Aw, this was an extremely good post. Finding the time and actual effort to generate a top
    notch article… but what can I say… I put things off a
    lot and don’t seem to get anything done.

  71. Oh my goodness! Impressive article dude! Thank you, However I am encountering problems with your RSS.
    I don’t know why I cannot subscribe to it.
    Is there anybody else having similar RSS issues? Anybody who knows
    the answer can you kindly respond? Thanks!!

  72. Greetings from California! I’m bored at work so I decided to check out your blog on my iphone during lunch break.

    I enjoy the information you provide here and can’t wait to take
    a look when I get home. I’m amazed at how fast your blog loaded on my phone
    .. I’m not even using WIFI, just 3G .. Anyhow, amazing
    blog!

  73. After I originally left a comment I seem to have clicked on the -Notify me when new comments are added- checkbox
    and from now on every time a comment is added I receive four emails with the exact same comment.
    Perhaps there is an easy method you are able to remove me from that service?
    Thank you!

  74. Undeniably believe that which you said. Your favorite justification appeared to be on the internet the easiest thing to be aware of.
    I say to you, I certainly get irked while people consider worries that they just do not know
    about. You managed to hit the nail upon the top as well
    as defined out the whole thing without having side effect ,
    people can take a signal. Will likely be back to get more.
    Thanks

  75. Do you have a spam issue on this website; I also
    am a blogger, and I was wanting to know your situation; we have created some
    nice practices and we are looking to trade strategies
    with other folks, why not shoot me an e-mail if interested.

  76. Write more, thats all I have to say. Literally, it seems as though you
    relied on the video to make your point. You obviously know what youre talking about, why waste your intelligence
    on just posting videos to your weblog when you could be giving us something enlightening to read?

  77. Hi, I think your site might be having browser compatibility issues.
    When I look at your website in Ie, it looks fine but when opening in Internet Explorer, it has
    some overlapping. I just wanted to give you a quick heads
    up! Other then that, amazing blog!

  78. It is the best time to make some plans for the long run and it is time to be happy.
    I’ve learn this submit and if I could I desire to suggest you some
    interesting things or tips. Perhaps you can write next articles regarding
    this article. I wish to read more issues about it!

  79. It’s perfect time to make some plans for the future and it is time to be happy.

    I have read this post and if I could I want to suggest you few interesting things or tips.
    Maybe you can write next articles referring to this article.

    I desire to read even more things about it!

  80. Oh my goodness! Amazing article dude! Many thanks,
    However I am having problems with your RSS. I don’t understand the reason why I cannot join it.
    Is there anybody else having the same RSS problems? Anyone that knows the
    solution can you kindly respond? Thanks!!

  81. Have you ever considered publishing an ebook or
    guest authoring on other blogs? I have a blog based on the same topics you discuss and would really like to have you share some stories/information. I know my readers would enjoy your work.
    If you’re even remotely interested, feel free to send me an e-mail.

  82. Howdy! I just would like to offer you a big thumbs up for the
    great info you’ve got right here on this post. I am returning to your blog
    for more soon. natalielise pof

  83. Fantastic goods from you, man. I’ve understand your stuff
    previous to and you are just too fantastic. I actually like what you’ve acquired here, certainly like what you are saying and the way in which you say
    it. You make it enjoyable and you still take care of to keep it wise.
    I can’t wait to read much more from you. This is really a
    tremendous web site.

  84. Just desire to say your article is as astounding.
    The clearness in your post is simply excellent and i can assume you’re an expert on this subject.
    Fine with your permission let me to grab your feed to keep updated with forthcoming post.
    Thanks a million and please carry on the rewarding work.

  85. We are a bunch of volunteers and starting a brand new
    scheme in our community. Your site offered us with valuable info to work on. You’ve performed
    an impressive process and our entire community can be thankful to you.

  86. I’m impressed, I must say. Rarely do I encounter a blog that’s both educative
    and amusing, and without a doubt, you have hit the nail on the head.
    The problem is an issue that too few men and
    women are speaking intelligently about. I’m very happy that I stumbled across this in my hunt for something concerning this.

  87. If some one desires expert view regarding blogging and site-building after that i suggest
    him/her to visit this web site, Keep up the pleasant
    work.

  88. It’s really a great and helpful piece of info. I’m glad that you simply shared this helpful information with us.
    Please keep us up to date like this. Thanks for sharing.

  89. You’re so awesome! I don’t believe I’ve truly read anything like that before.
    So great to discover somebody with a few original thoughts on this issue.

    Seriously.. thanks for starting this up. This website is something that’s needed
    on the web, someone with a bit of originality!

  90. Have you ever considered creating an ebook or guest authoring on other websites?
    I have a blog centered on the same topics you discuss and would really
    like to have you share some stories/information. I know my subscribers would appreciate your work.

    If you are even remotely interested, feel free to shoot me an e mail.
    natalielise pof

  91. Good day very cool website!! Man .. Beautiful ..
    Wonderful .. I’ll bookmark your blog and take the feeds additionally?
    I’m satisfied to seek out a lot of helpful info here within the submit,
    we need develop extra strategies on this regard, thanks for sharing.

    . . . . . pof natalielise

  92. Hi there! I just want to offer you a big thumbs up for the great info you have got here on this post.
    I’ll be returning to your site for more soon.

  93. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something.

    I think that you can do with some pics to drive the message home a
    bit, but other than that, this is fantastic blog. A fantastic read.
    I’ll certainly be back. pof natalielise

  94. You really make it appear really easy with your presentation however
    I to find this topic to be really something that
    I think I might by no means understand. It seems too complicated and extremely large for me.
    I am taking a look ahead to your subsequent submit, I’ll try to get the hold of it!

  95. We are a bunch of volunteers and starting a new scheme in our community.
    Your web site provided us with valuable information to work on. You’ve
    performed an impressive activity and our entire group
    can be grateful to you.

  96. Have you ever considered about adding a little bit more than just your articles?
    I mean, what you say is fundamental and everything.
    But just imagine if you added some great photos or videos to
    give your posts more, “pop”! Your content is excellent but with
    images and video clips, this website could certainly be one of
    the best in its niche. Amazing blog!

  97. You could certainly see your enthusiasm within the work you write.

    The sector hopes for even more passionate writers like you who are not afraid
    to mention how they believe. Always go after your heart.

发表评论

电子邮件地址不会被公开。 必填项已用*标注