From a16d8f66a99ae365a57d114d5ee7d0a7ebc4cf5f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 9 Jan 2017 09:52:17 +0900 Subject: Normalize pattern string before passing it to Algo function --- src/algo/normalize.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/algo/normalize.go') diff --git a/src/algo/normalize.go b/src/algo/normalize.go index 1168a646..7a496441 100644 --- a/src/algo/normalize.go +++ b/src/algo/normalize.go @@ -406,3 +406,19 @@ var normalized map[rune]rune = map[rune]rune{ 0x028F: 'Y', // , LATIN LETTER SMALL CAPITAL 0x1D22: 'Z', // , LATIN LETTER SMALL CAPITAL } + +// NormalizeRunes normalizes latin script letters +func NormalizeRunes(runes []rune) []rune { + ret := make([]rune, len(runes)) + copy(ret, runes) + for idx, r := range runes { + if r < 0x00C0 || r > 0x2184 { + continue + } + n := normalized[r] + if n > 0 { + ret[idx] = normalized[r] + } + } + return ret +} -- cgit v1.2.3