Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of Latin-Extended-A to removeAccents #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions src/String/Extra.elm
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,136 @@ accentRegex =
, ( "ý", "y" )
, ( "ÿ", "y" )
, ( "Ý", "Y" )

-- Latin Extended-A
, ( "Ā", "A" )
, ( "ā", "a" )
, ( "Ă", "A" )
, ( "ă", "a" )
, ( "Ą", "A" )
, ( "ą", "a" )
, ( "Ć", "C" )
, ( "ć", "c" )
, ( "Ĉ", "C" )
, ( "ĉ", "c" )
, ( "Ċ", "C" )
, ( "ċ", "c" )
, ( "Č", "C" )
, ( "č", "c" )
, ( "Ď", "D" )
, ( "ď", "d" )
, ( "Đ", "D" )
, ( "đ", "d" )
, ( "Ē", "e" )
, ( "ē", "e" )
, ( "Ĕ", "E" )
, ( "ĕ", "e" )
, ( "Ė", "E" )
, ( "ė", "e" )
, ( "Ę", "E" )
, ( "ę", "e" )
, ( "Ě", "E" )
, ( "ě", "e" )
, ( "Ĝ", "G" )
, ( "ĝ", "g" )
, ( "Ğ", "G" )
, ( "ğ", "g" )
, ( "Ġ", "G" )
, ( "ġ", "g" )
, ( "Ģ", "G" )
, ( "ģ", "g" )
, ( "Ĥ", "H" )
, ( "ĥ", "h" )
, ( "Ħ", "H" )
, ( "ħ", "h" )
, ( "Ĩ", "I" )
, ( "ĩ", "i" )
, ( "Ī", "I" )
, ( "ī", "i" )
, ( "Ĭ", "I" )
, ( "ĭ", "i" )
, ( "Į", "I" )
, ( "į", "i" )
, ( "İ", "I" )
, ( "ı", "i" )
, ( "IJ", "IJ" )
, ( "ij", "ij" )
, ( "Ĵ", "J" )
, ( "ĵ", "j" )
, ( "Ķ", "K" )
, ( "ķ", "k" )
, ( "ĸ", "K" )
, ( "Ĺ", "L" )
, ( "ĺ", "l" )
, ( "Ļ", "L" )
, ( "ļ", "l" )
, ( "Ľ", "L" )
, ( "ľ", "l" )
, ( "Ŀ", "L" )
, ( "ŀ", "l" )
, ( "Ł", "L" )
, ( "ł", "l" )
, ( "Ń", "N" )
, ( "ń", "n" )
, ( "Ņ", "N" )
, ( "ņ", "n" )
, ( "Ň", "N" )
, ( "ň", "n" )
, ( "ʼn", "n" )
, ( "Ŋ", "N" )
, ( "ŋ", "n" )
, ( "Ō", "O" )
, ( "ō", "o" )
, ( "Ŏ", "O" )
, ( "ŏ", "o" )
, ( "Ő", "O" )
, ( "ő", "o" )
, ( "Œ", "OE" )
, ( "œ", "oe" )
, ( "Ŕ", "R" )
, ( "ŕ", "r" )
, ( "Ŗ", "R" )
, ( "ŗ", "r" )
, ( "Ř", "R" )
, ( "ř", "r" )
, ( "Ś", "S" )
, ( "ś", "s" )
, ( "Ŝ", "S" )
, ( "ŝ", "s" )
, ( "Ş", "S" )
, ( "ş", "s" )
, ( "Š", "S" )
, ( "š", "s" )
, ( "Ţ", "T" )
, ( "ţ", "t" )
, ( "Ť", "T" )
, ( "ť", "t" )
, ( "Ŧ", "T" )
, ( "ŧ", "t" )
, ( "Ũ", "U" )
, ( "ũ", "u" )
, ( "Ū", "U" )
, ( "ū", "u" )
, ( "Ŭ", "U" )
, ( "ŭ", "u" )
, ( "Ů", "U" )
, ( "ů", "u" )
, ( "Ű", "U" )
, ( "ű", "u" )
, ( "Ų", "U" )
, ( "ų", "u" )
, ( "Ŵ", "W" )
, ( "ŵ", "w" )
, ( "Ŷ", "Y" )
, ( "ŷ", "y" )
, ( "Ÿ", "Y" )
, ( "Ź", "Z" )
, ( "ź", "z" )
, ( "Ż", "Z" )
, ( "ż", "z" )
, ( "Ž", "Z" )
, ( "ž", "z" )
, ( "ſ", "s" )
]
in
List.map (Tuple.mapFirst regexFromString) matches
Expand Down
8 changes: 6 additions & 2 deletions tests/RemoveAccentsTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ removeAccentsTest =
describe "removeAccents"
[ test "Should result string without accents" <|
\() ->
removeAccents "áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ"
|> Expect.equal "aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC"
removeAccents "ąáàãâäćęéèêëíìîïłóòõôöśúùûüçźżĄÁÀÃÂÄĆĘÉÈÊËÍÌÎÏŁÓÒÕÖÔŚÚÙÛÜÇŹŻ"
|> Expect.equal "aaaaaaceeeeeiiiilooooosuuuuczzAAAAAACEEEEEIIIILOOOOOSUUUUCZZ"
, test "Should result in phrase without accents" <|
\() ->
removeAccents "andré JOÂO"
|> Expect.equal "andre JOAO"
, test "Should produce a Polish phrase without accents" <|
\() ->
removeAccents "Cześć! Jak się masz? Śmiało usuń akcenty!"
|> Expect.equal "Czesc! Jak sie masz? Smialo usun akcenty!"
]