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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -