iPhone : How to insert utf-8 mb4 character(emoji in ios5) in mysql? - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Monday, February 15, 2016

iPhone : How to insert utf-8 mb4 character(emoji in ios5) in mysql?

4 byte Unicode characters aren't yet widely used, so not every application out there fully supports them. MySQL 5.5 works fine with 4 byte characters when properly configured – check if your other components can work with them as well.

Here's a few other things to check out:
  • Make sure all your tables' default character sets and text fields are converted to utf8mb4, in addition to setting the client & server character sets, e.g. ALTER TABLE mytable charset=utf8mb4, MODIFY COLUMN textfield1 VARCHAR(255) CHARACTER SET utf8mb4,MODIFY COLUMN textfield2 VARCHAR(255) CHARACTER SET utf8mb4; and so on.
    ​ ​
    If your data is already in the utf8 character set, it should convert to utf8mb4 in place without any problems. As always, back up your data before trying!
  • Also make sure your app layer sets its database connections' character set to utf8mb4. Double-check this is actually happening – if you're running an older version of your chosen framework's mysql client library, it may not have been compiled with utf8mb4 support and it won't set the charset properly. If not, you may have to update it or compile it yourself.
    ​ ​
    To verify this, use this command grep -R "SET NAMES" *
  • When viewing your data through the mysql client, make sure you're on a machine that can display emoji, and run a SET NAMES utf8mb4 before running any queries.
Once every level of your application can support the new characters, you should be able to use them without any corruption.

A good tutorial on it can be found from here.
https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4

I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too. 

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.

No comments:

Post a Comment