diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2020-01-15 18:00:41 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2020-01-15 18:49:57 -0500 |
| commit | 2fbcfc68d2b8f948053f02f73f6e01a7fb7724cb (patch) | |
| tree | bcd62b43da4040fd4d589bbe044fb1b42979e716 /vendor/github.com/rainycape/unidecode/unidecode.go | |
| parent | 42bfed36830e6682612f05f67c6543c2613f8e59 (diff) | |
Removing vendor/ folder
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'vendor/github.com/rainycape/unidecode/unidecode.go')
| -rw-r--r-- | vendor/github.com/rainycape/unidecode/unidecode.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/vendor/github.com/rainycape/unidecode/unidecode.go b/vendor/github.com/rainycape/unidecode/unidecode.go deleted file mode 100644 index 16281da4..00000000 --- a/vendor/github.com/rainycape/unidecode/unidecode.go +++ /dev/null @@ -1,58 +0,0 @@ -// Package unidecode implements a unicode transliterator -// which replaces non-ASCII characters with their ASCII -// approximations. -package unidecode - -//go:generate go run make_table.go - -import ( - "sync" - "unicode" -) - -const pooledCapacity = 64 - -var ( - slicePool sync.Pool - decodingOnce sync.Once -) - -// Unidecode implements a unicode transliterator, which -// replaces non-ASCII characters with their ASCII -// counterparts. -// Given an unicode encoded string, returns -// another string with non-ASCII characters replaced -// with their closest ASCII counterparts. -// e.g. Unicode("áéíóú") => "aeiou" -func Unidecode(s string) string { - decodingOnce.Do(decodeTransliterations) - l := len(s) - var r []rune - if l > pooledCapacity { - r = make([]rune, 0, len(s)) - } else { - if x := slicePool.Get(); x != nil { - r = x.([]rune)[:0] - } else { - r = make([]rune, 0, pooledCapacity) - } - } - for _, c := range s { - if c <= unicode.MaxASCII { - r = append(r, c) - continue - } - if c > unicode.MaxRune || c > transCount { - /* Ignore reserved chars */ - continue - } - if d := transliterations[c]; d != nil { - r = append(r, d...) - } - } - res := string(r) - if l <= pooledCapacity { - slicePool.Put(r) - } - return res -} |
