emoji-picker
emoji-picker copied to clipboard
How to show emoji on p / span tag
We create emoji then save it to db, after that how to show the emoji that we saved into p or span tag ?
there's no further explanation on this, so i try myself and create js function
function showsmiley( input) { var k, len, split_on_unicode, text, val; if (!input) { return ''; } if (!Config.rx_codes) { Config.init_unified(); } split_on_unicode = input.split(Config.rx_codes); for (k = 0, len = split_on_unicode.length; k < len; k++) { text = split_on_unicode[k]; val = ''; if (Config.rx_codes.test(text)) { val = Config.reversemap[text]; if (val) { val = ':' + val + ':'; val = $.emojiarea.createIcon($.emojiarea.icons[val]); } } else { // val = document.createTextNode(text); } // element.append(val); } return input.replace(Config.rx_codes, function(m) { var $img; val = Config.reversemap[m]; if (val) { val = ':' + val + ':'; $img = $.emojiarea.createIcon($.emojiarea.icons[val]); return $img; } else { return ''; } }); };
and this is how to call it showsmiley(yourunicodeinput);
Your database probably needs to be configured to accept 4 byte utf-8 characters. Here's the documentation for mysql.