Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const str = '\u0065\u0301'
- console.log(str == '\u00e9') // => false
- const normalized = str.normalize('NFC')
- console.log(normalized == '\u00e9') // => true
- console.log(normalized.length) // => 1
- // In short, if you’re building a web application and you’re accepting input from users, you should always normalize it to a canonical form in Unicode.
- With JavaScript, you can use the String.prototype.normalize() method, which is built-in since ES2015.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement