Created
August 31, 2023 07:52
-
-
Save gaborbata/3ff555352b31049bef97c9b7ade5b58e to your computer and use it in GitHub Desktop.
Ruby method to remove accents from UTF-8 international characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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