Closed jacgrady1 closed 3 years ago
I found nodejs does not properly handle emojis properly (or didn't, I don't know the latest version). A year ago I wrote this:
function encode_emojis(s) {
return s.replace(/[\u007f-\uffff]/g, (c) => ('\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4)));
};
Try it before passing the string to orm.
I too am experiencing a lot of trouble implementing support for emojis.
@dxg How would I apply this charset option in orm2?
@lawrencebensaid add ?charset=utf8mb4
to your connection string or query: { charset: utf8mb4' }
to your connection object.
I've added a test for this as well as examples in the doco.
This will only work if your database was created with utf8mb4
encoding. This is the default encoding in MySQL 8 & newer.
orm truncate the state from the unicode escape sequence, after executing the query,
state = 'abc';