1 parent a1b4a21 commit 9f0d5f3Copy full SHA for 9f0d5f3
1 file changed
decritic.go
@@ -1,3 +1,6 @@
1
+// Command decritic reads text (from its arguments, or from stdin line by line)
2
+// and removes diacritics (accents), optionally applying extended
3
+// transliterations for letters that have no simple decomposed form.
4
package main
5
6
import (
@@ -43,6 +46,8 @@ func action(c *cli.Context) error {
43
46
"ł", "l", "Ł", "L",
44
47
)
45
48
49
+ // Decompose to NFD, drop the combining marks (Unicode category Mn) that
50
+ // carry the accents, then recompose to NFC.
51
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
52
if c.NArg() > 0 {
53
for i, in := range c.Args().Slice() {
0 commit comments