Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show emoji on p / span tag #134

Open
fammifarendra opened this issue Feb 15, 2019 · 2 comments
Open

How to show emoji on p / span tag #134

fammifarendra opened this issue Feb 15, 2019 · 2 comments

Comments

@fammifarendra
Copy link

We create emoji then save it to db, after that how to show the emoji that we saved into p or span tag ?

@fammifarendra
Copy link
Author

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);

@patrick-mcdougle
Copy link

Your database probably needs to be configured to accept 4 byte utf-8 characters. Here's the documentation for mysql.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants