Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. const str = '\u0065\u0301'
  2. console.log(str == '\u00e9') // => false
  3. const normalized = str.normalize('NFC')
  4. console.log(normalized == '\u00e9') // => true
  5. console.log(normalized.length) // => 1
  6.  
  7. // 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.
  8. 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