Created
July 30, 2020 15:32
-
-
Save remvee/4962dfbfc703db262135c42cb4660172 to your computer and use it in GitHub Desktop.
Transliterate latin diacritics to ascii.
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
(let [trans {#"[ÁĂÂÄÀĀĄÅÃ]" "A" | |
#"[áăâäàāąåã]" "a" | |
#"Æ" "AE" | |
#"æ" "ae" | |
#"[ĆČÇĈĊ]" "C" | |
#"[ćčçĉċ]" "c" | |
#"[ĎĐ]" "D" | |
#"[ďđ]" "d" | |
#"[ÉĔĚÊËĖÈĒĘÐ]" "E" | |
#"[éĕěêëėèēęð]" "e" | |
#"[ĞĢĜĠ]" "G" | |
#"[ğģĝġ]" "g" | |
#"[ĤĦ]" "H" | |
#"[ĥħ]" "h" | |
#"[ÍĬÎÏİÌĪĮĨ]" "I" | |
#"[ıíĭîïìīįĩ]" "i" | |
#"IJ" "IJ" | |
#"ij" "ij" | |
#"Ĵ" "J" | |
#"ĵ" "j" | |
#"Ķ" "K" | |
#"[ķĸ]" "k" | |
#"[ĹĽĻĿŁ]" "L" | |
#"[ĺľļŀł]" "l" | |
#"[ŊŃŇŅÑ]" "N" | |
#"[ŋńňņʼnñ]" "n" | |
#"Œ" "OE" | |
#"œ" "oe" | |
#"[ÓŎÔÖÒŌØÕŐ]" "O" | |
#"[óŏôöòōøõő]" "o" | |
#"Þ" "P" | |
#"þ" "p" | |
#"[ŔŘŖ]" "R" | |
#"[ŕřŗ]" "r" | |
#"[ŚŠŞŜ]" "S" | |
#"[ſśšşŝ]" "s" | |
#"ß" "ss" | |
#"[ŤŢŦ]" "T" | |
#"[ťţŧ]" "t" | |
#"[ÚŬÛÜŰÙŪŲŨŮ]" "U" | |
#"[úŭûüűùūųũů]" "u" | |
#"Ŵ" "W" | |
#"ŵ" "w" | |
#"[ÝŶŸ]" "Y" | |
#"[ýŷÿ]" "y" | |
#"[ŹŽŻ]" "Z" | |
#"[źžż]" "z"}] | |
(defn translit-to-ascii | |
"Transliterate given string to ascii only characters." | |
[s] | |
(reduce (fn [s [m r]] (string/replace s m r)) | |
s | |
trans))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment