I have string 00B0 which is Unicode of degree sign how can I convert in to symbol?
var str = "00B0";
var degreeSign = convesion(str);
console.log(degreeSign);
How it possible ?
Parse the string into a number to get the character code, then use the String.fromCharCode
method to create a string from it:
var degreeSign = String.fromCharCode(parseInt(str, 16));
console.log('\u00B0'); // outputs ° in my chrome console
so basically: '\u00B0'
You can use Unicode characters in HTML by following this example
°
The degrees sign will appear like so: °
edit: Except this question is tagged as Node.js. What is the purpose of getting the symbol? Is it front-end or back-end?
If you're sure your string is well formed, you could also do it like this:
var degreeSign = eval("('\\u" + str + "')");