Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the character code for ♥ and how to use it?

im creating a emoticon js script and i cant seem to get the character code for to work ive tried ♥ as the character code but dosen't work any help would be help ful

my script

jQuery.fn.emotion_func = function(icon_folder) {
var emotion_locate =  "emotions";
var key_stroke = { ....
         "heart": Array("♥")//it dosent work 
                   ....
             };

function emotion_func(html){
for(var emotion in key_stroke){
    for(var i = 0; i < key_stroke[emotion].length; i++){
        var key = new RegExp(key_stroke[emotion][i],"g");//replace all occurenced
        html = html.replace(key,"<span style=\"background-image:url("+emotion_locate+"/"+emotion+".png); \" title="+emotion+" /></span>");
                }
            }
            return html;
        }
        return this.each(function(){
            $(this).html(emotion_func($(this).html()));
        });
    };

Any Help would be appreciated

Also note that im using html 5

Sorry but only @hwnd's answer worked for me

like image 927
Dev Man Avatar asked Oct 11 '25 15:10

Dev Man


2 Answers

You want to actually use the Unicode escape sequence \u2665 in your array for replacement.

var key_stroke = { 'heart': Array('\u2665') };
like image 158
hwnd Avatar answered Oct 14 '25 04:10

hwnd


The term you're looking for is "entity." There are only a few named entities in HTML, but you can specify any character by its unicode ID:

&#x2665; will show up as: ♥

like image 40
adv12 Avatar answered Oct 14 '25 04:10

adv12



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!