PROJET AUTOBLOG


Shaarli - le hollandais volant

Site original : Shaarli - le hollandais volant

⇐ retour index

javascript - How can I convert a string into a unicode character? - Stack Overflow

samedi 30 mai 2015 à 18:50
En JS, si vous souhaitez transformer un code « u263A » en son caractère correspondant, il faut utiliser « eval() ».

C’est mal (eval est très lourd). Il faut mieux utiliser String.fromCharCode(parseInt('263A',16))

Et on obtient le caractère : ☺.

Ex:
var caractere = String.fromCharCode(parseInt('263A',16));
alert(caractere);

— (permalink)