Source File
unidecode.go
Belonging Package
github.com/gosimple/unidecode
// Package unidecode implements a unicode transliterator// which replaces non-ASCII characters with their ASCII// approximations.package unidecode//go:generate go run make_table.goimport ()const pooledCapacity = 64var (slicePool sync.PooldecodingOnce 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 ( string) string {decodingOnce.Do(decodeTransliterations):= len()var []runeif > pooledCapacity {= make([]rune, 0, len())} else {if := slicePool.Get(); != nil {= .([]rune)[:0]} else {= make([]rune, 0, pooledCapacity)}}for , := range {if <= unicode.MaxASCII {= append(, )continue}if > unicode.MaxRune || >= transCount {/* Ignore reserved chars */continue}if := transliterations[]; != nil {= append(, ...)}}:= string()if <= pooledCapacity {slicePool.Put()}return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |