Julien Enselme personal blog

  • Archives
  • Categories
  • Tags
  • Atom Feed
  • Trucs et astuces Atom Feed
  • Privacy

JavaScript tips

Published: 2018-03-07 by Julien Enselme in Trucs et astuces • Tagged with: JavaScript

Contents

  • Normalize an UTF-8 string

Normalize an UTF-8 string

Rely on String.prototype.normalize().

const str = "Crème Brulée"
str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
> 'Creme Brulee'

Source: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463

© Julien Enselme

This work is licensed under a Creative Commons Attribution-ShareAlike

Creative Commons License

Proudly powered by Pelican