javascript - Replace emoticons with emoji -


i've text, may include text emoticons (eg: ;), :(). i'd replace these corresponding emoji unicode characters (😉 , 😞) above example.

my intention run twimoji on text.

i know can find-and-replace, i'd rather use pre-build already.

any libraries implement this? believe list of common emoticons largest bit of work here.

not sure if there's library out there turns text emoticons unicode characters here's example of how possibly implement yourself.

 var map = {    "<3": "\u2764\ufe0f",    "</3": "\ud83d\udc94",    ":d": "\ud83d\ude00",    ":)": "\ud83d\ude03",    ";)": "\ud83d\ude09",    ":(": "\ud83d\ude12",    ":p": "\ud83d\ude1b",    ";p": "\ud83d\ude1c",    ":'(": "\ud83d\ude22"  };   function escapespecialchars(regex) {    return regex.replace(/([()[{*+.$^\\|?])/g, '\\$1');  }   document.getelementbyid('textarea').oninput = function() {    (var in map) {      var regex = new regexp(escapespecialchars(i), 'gim');      this.value = this.value = this.value.replace(regex, map[i]);    }  }; 

http://jsfiddle.net/04zv3ozh/18/


Comments

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

Python website log in: BIG-IP can not find session information in the request -