I have a problem saving emoji to the Oracle database. This is a simple Java program which takes user input from the webpage and save it to the database.
This is what it looks like before I save to DB.
And this is what it looks like when it retrieves it from database.
The database column defined as CLOB
so my expectation that it persist text with emoji just fine.
I also tried to save and retrieve emoji with sqlplus and have no luck as well:
SQL> update emoji_table set emoji_column = 'Test ' where emoji_table_id = 123;
1 row updated.
SQL> select emoji_column from emoji_table where emoji_table_id = 123;
EMOJI_TABLE
--------------------------------------------------------------------------------
Test ????
I assume there might be an issue with Oracle character encoding or something like that. Could you please advice what might be wrong and where to look for potential fix.
Thank you
UPDATE #1
As suggested by Wernfried Domscheit I checked my NLS_CHARACTERSET and it appears to be WE8MSWIN1252.
As I understand this is the root cause of the issue, it is not UTF-8, hence doesn't have reserved list of emoji.
The output of the
select DUMP(emoji_column, 1016) from emoji_table where emoji_table_id = 123
is following
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got CLOB
Could you please advice how to workaround?
UPDATE #2
Here is the output of DUMP sql query:
select DUMP(TO_CHAR(emoji_column), 1016) from emoji_table where emoji_table_id = 123
DUMP(TO_CHAR(TEMPLATE),1016)
--------------------------------------------------------------------------------
Typ=1 Len=6 CharacterSet=WE8MSWIN1252: 42,6f,64,79,20,bf
As I can see CharacterSet is WE8MSWIN1252
which matches the NLS_CHARACTERSET
of the Oracle instance.
Is there a workaround to save emoji with WE8MSWIN1252
?
Probably Base64
encoding could be a workaround but I would like to know if there is a better solution.