示例#1
0
文件: main.go 项目: Olbitla/photopy
func textilize(input string) string {
	sc := unicode.SpecialCase{}

	output := strings.ToLowerSpecial(sc, input)

	output = reSpecialA.ReplaceAllLiteralString(output, "a")

	output = reSpecialE.ReplaceAllLiteralString(output, "e")

	output = reSpecialI.ReplaceAllLiteralString(output, "i")

	output = reSpecialO.ReplaceAllLiteralString(output, "o")

	output = reSpecialU.ReplaceAllLiteralString(output, "u")

	output = reSpecialN.ReplaceAllLiteralString(output, "n")

	output = reSpecialNotAlpha.ReplaceAllLiteralString(output, " ")

	output = reSpecialSpaces.ReplaceAllLiteralString(output, " ")

	output = strings.Replace(strings.TrimSpace(output), " ", "_", -1)

	return output
}
示例#2
0
文件: main.go 项目: sjn1978/go-fuzz
func Fuzz(data []byte) int {
	s := string(data)
	si := len(s) / 4 * 3
	s0 := s[:si]
	s1 := s[si:]
	s2, r := splitRune(s)
	s3 := s[:len(s)/2]
	s4 := s[len(s)/2:]
	s5 := s[:len(s)/3]
	s6 := s[len(s)/3 : len(s)/3*2]
	s7 := s[len(s)/3*2:]

	strings.Contains(s0, s1)
	strings.ContainsAny(s0, s1)
	strings.ContainsRune(s, r)
	strings.Count(s0, s1)
	strings.EqualFold(s3, s4)
	fields := strings.Fields(s)
	strings.HasPrefix(s0, s1)
	strings.HasSuffix(s0, s1)
	strings.Index(s0, s1)
	strings.IndexAny(s0, s1)
	strings.IndexByte(s2, byte(r))
	strings.IndexRune(s2, r)
	strings.Join(fields, " ")
	strings.LastIndex(s0, s1)
	strings.LastIndexAny(s0, s1)
	strings.Repeat(s, 2)
	strings.Replace(s, s0, s1, -1)
	strings.Split(s0, s1)
	strings.SplitAfter(s0, s1)
	strings.SplitAfterN(s0, s1, 2)
	strings.SplitN(s0, s1, 2)
	strings.Title(s)
	strings.ToLower(s)
	strings.ToLowerSpecial(unicode.AzeriCase, s)
	strings.ToTitle(s)
	strings.ToTitleSpecial(unicode.AzeriCase, s)
	strings.ToUpper(s)
	strings.ToUpperSpecial(unicode.AzeriCase, s)
	strings.Trim(s0, s1)
	strings.TrimLeft(s0, s1)
	strings.TrimPrefix(s0, s1)
	strings.TrimRight(s0, s1)
	strings.TrimSpace(s)
	strings.TrimSuffix(s0, s1)
	strings.NewReplacer(s5, s6).Replace(s7)
	return 0
}
示例#3
0
func NormalizeAddress(input string) string {
	parts := strings.SplitN(input, "@", 2)

	return NormalizeUsername(parts[0]) + "@" + strings.ToLowerSpecial(unicode.TurkishCase, parts[1])
}
示例#4
0
func NormalizeUsername(input string) string {
	return rNotASCII.ReplaceAllString(
		strings.ToLowerSpecial(unicode.TurkishCase, input),
		"",
	)
}
示例#5
0
/*
_case 规则说明,以下列语句为例:
unicode.CaseRange{'A', 'Z', [unicode.MaxCase]rune{3, -3, 0}}
·其中 'A', 'Z' 表示此规则只影响 'A' 到 'Z' 之间的字符。
·其中 [unicode.MaxCase]rune 数组表示:
当使用 ToUpperSpecial 转换时,将字符的 Unicode 编码与第一个元素值(3)相加
当使用 ToLowerSpecial 转换时,将字符的 Unicode 编码与第二个元素值(-3)相加
当使用 ToTitleSpecial 转换时,将字符的 Unicode 编码与第三个元素值(0)相加

*/
func main() {
	var SC unicode.SpecialCase
	fmt.Println(strings.ToLowerSpecial(SC, "Gopher"))
	//gopher
}
示例#6
0
// ToLowerSpecial returns a copy of the string s with all Unicode letters mapped to their lower case
// giving priority to the special casing rules
func ToLowerSpecial(_case unicode.SpecialCase, s string) string {
	fmt.Println(strings.ToLowerSpecial(unicode.AzeriCase, "ŞĞÜÖIİ")) // şğüöıi
	return strings.ToLowerSpecial(_case, s)
}