How to convert unicode escape sequences to unicode characters in react javascript.
Informaci\ón
should get converted to its relevant unicode character string, ie, Información
Try the bellow function.
function unicodeToChar(text) { return text.replace(/\\\\u[\\dA-F]{4}/gi, function (match) { return String.fromCharCode(parseInt(match.replace(/\\\\u/g, ''), 16)); }); } console.log(unicodeToChar('Informaci\ón'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.