代码拉取完成,页面将自动刷新
package devstatscode
import (
"strings"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
// StripUnicode strip non-unicode and control characters from a string
// From: https://rosettacode.org/wiki/Strip_control_codes_and_extended_characters_from_a_string#Go
func StripUnicode(str string) string {
isOk := func(r rune) bool {
return r < 32 || r >= 127
}
t := transform.Chain(norm.NFKD, transform.RemoveFunc(isOk))
str, _, _ = transform.String(t, str)
return str
}
// NormalizeName - clean DB string from ", ', -, /, ., " ",), (, ], [ trim leading and trailing space, lowercase
// Normalize Unicode characters
func NormalizeName(str string) string {
r := strings.NewReplacer(
"-", "", "/", "", ".", "", " ", "", ",", "", ";", "", ":", "", "`", "", "(", "", ")", "", "[", "", "]", "", "<", "", ">", "", "_", "", "\"", "", "'", "",
)
return r.Replace(strings.ToLower(strings.TrimSpace(StripUnicode(str))))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。