I am adding the emojis using their html codes (example: & # 1 2 8 0 7 0 ; ) using a javascript function in a contenteditable html element which displays the emoji (example: )
I then retrieve the content of the element with
var content = el.innerText;
I add the content in a json
var myjson = {"content" : content};
I send the json through ajax with content-type being
application/json
In, the backend i convert the json to a pojo using Gson, then persist it in the database using hibernate
In the servlet, using system.out.println, the content displays as ð in the db, a select query displays it as ð (with small numbers inside the rectangles)
I spent hours searching, setting the character set as utf8mb4 in the DB as well as the hibernate config file...example as described in the following links
Caused by: java.sql.SQLException: Unsupported character encoding 'utf8mb4'
How to store Emoji Character in MySQL Database
I'm a bit lost with it. My need is to persist a text containing emoji and be able to retrieve it(through hibernate or simple jdbc) and display it in a webpage.
What would be the best approach?