Files
lilypond-common-includes/private_includes/book/transliteration.ily

66 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#(define (transliterate-de str)
"Gesamte Transliteration: entfernt Diakritika, ersetzt Sonderzeichen, ergibt ASCII-String."
(define (remove-diacritics s)
(string-join
(map (lambda (ch)
(let ((code (char->integer ch)))
;; Unicode-Bereich 0300036F = Combining Diacritical Marks
(if (and (>= code #x0300) (<= code #x036F))
""
(string ch))))
(string->list (string-normalize-nfkd s)))
""))
(define transliteration-table
'(
;; Deutsche Umlaute & ß
("ä" . "ae") ("ö" . "oe") ("ü" . "ue")
("Ä" . "Ae") ("Ö" . "Oe") ("Ü" . "Ue")
("ß" . "ss")
;; Balkan & mitteleuropäische Sonderzeichen
("Č" . "C") ("č" . "c")
("Š" . "S") ("š" . "s")
("Ž" . "Z") ("ž" . "z")
("Đ" . "D") ("đ" . "d")
("Ł" . "L") ("ł" . "l")
("Ø" . "O") ("ø" . "o")
("Æ" . "Ae") ("æ" . "ae")
("Œ" . "Oe") ("œ" . "oe")
;; Kyrillische Buchstaben mit lateinischen Pendants
("А" . "A") ("а" . "a")
("Б" . "B") ("б" . "b")
("В" . "V") ("в" . "v")
("Г" . "G") ("г" . "g")
("Д" . "D") ("д" . "d")
("Е" . "E") ("е" . "e")
("З" . "Z") ("з" . "z")
("И" . "I") ("и" . "i")
("К" . "K") ("к" . "k")
("Л" . "L") ("л" . "l")
("М" . "M") ("м" . "m")
("Н" . "N") ("н" . "n")
("О" . "O") ("о" . "o")
("П" . "P") ("п" . "p")
("Р" . "R") ("р" . "r")
("С" . "S") ("с" . "s")
("Т" . "T") ("т" . "t")
("У" . "U") ("у" . "u")
("Ф" . "F") ("ф" . "f")
("Х" . "Kh") ("х" . "kh")
("Ц" . "Ts") ("ц" . "ts")
("Ч" . "Ch") ("ч" . "ch")
("Ш" . "Sh") ("ш" . "sh")
("Щ" . "Sch") ("щ" . "sch")
("Я" . "Ja") ("я" . "ja")
("Ю" . "Ju") ("ю" . "ju")
("Й" . "J") ("й" . "j")
))
(remove-diacritics
(fold (lambda (pair acc)
(ly:string-substitute (car pair) (cdr pair) acc))
str transliteration-table)))