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 ?
For the degree symbol, this is done by entering Ctrl + ⇧ Shift + U B 0 (where the last key is the number zero) followed by a space. For ChromeOS, use the Unicode entry method Ctrl + ⇧ Shift + U then 0 0 B 0 then space or return; with the UK extended layout, use AltGr + ⇧ Shift + 0 .
Insert the degree symbol by using a keyboard shortcut On your keyboard, press Alt + 0176. Note: This method works only for keyboards that include a 10-key numeric pad.
Use the string literal: \u00B0 . For Unicode characters, it will always be "\u" followed by the character code.
console.log('\u00B0'); // outputs ° in my chrome console
so basically: '\u00B0'
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With