Reputation: 873
How can I send text with emoji from Android app to server and save it correctly in MySql database?
In Android app I've pass some parametres with post method to php server, then I save it in to MySql database. But I've 2 problems with emoji 😫
Warning: #1366 Incorrect string value: '\xF0\x9F\x98\x8D' for column 'name' at row 1
. The table and the field have utf8mb4_bin collation.Upvotes: 2
Views: 1639
Reputation: 4917
You can use StringEscapeUtils Apache Library https://commons.apache.org/proper/commons-lang/download_lang.cgi
For saving the unicodes in database you have to encode them. So send your unicodes to server by encoding like
StringEscapeUtils.escapeJava(/* string message*/)
For displaying the encoded unicode in android
StringEscapeUtils.unescapeJava(/* string message*/)
Upvotes: 6