Tuesday, 8 March 2022

How to get the accent/diacritic of a letter in javascript?

I want to get the accent/diacritic of a letter in javascript.

For example:

  • ñ -> ~
  • á -> ´
  • è -> `

I tried using .normalize("NFD") but it doesn't return the correct accent/diacritc

string = "á"
string.normalize("NFD").split("")
// ['a', '́']
string.normalize("NFD").split("").includes("´") 
// false
'́' === "´"
// false


from How to get the accent/diacritic of a letter in javascript?

No comments:

Post a Comment