How can I convert the HTML entities € ► ♠ to their actual characters € ► ♠ using JavaScript?
How can I convert the HTML entities € ► ♠ to their actual characters
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An example would be:
alert(String.fromCharCode(8364));Where 8364 is the number of the HTML entity.
To replace a full body of text automatically then you will need to use this regular expression replacement example:
The magic happens here:
replace(/&#(\d{1,4});/g, function(fullStr, code) { return String.fromCharCode(code); });The first argument to replace,
/&#(\d{1,4});/g, specifies 1 to 4 digits surrounded by &# and ; respectively. The second parameter,function(fullStr, code) [...]does the replacement, wherecodeis the digits.