Skip to content

Instantly share code, notes, and snippets.

@gaborbata
Created August 31, 2023 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaborbata/3ff555352b31049bef97c9b7ade5b58e to your computer and use it in GitHub Desktop.
Save gaborbata/3ff555352b31049bef97c9b7ade5b58e to your computer and use it in GitHub Desktop.
Ruby method to remove accents from UTF-8 international characters
DIACRITICS = [*0x1DC0..0x1DFF, *0x0300..0x036F, *0xFE20..0xFE2F].pack('U*')
def removeaccents(str)
str
.unicode_normalize(:nfd)
.tr(DIACRITICS, '')
.unicode_normalize(:nfc)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment