示例#1
0
func ExampleRemove() {
	t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
	s, _, _ := transform.String(t, "résumé")
	fmt.Println(s)

	// Output:
	// resume
}
示例#2
0
func ExampleIn() {
	// Convert Latin characters to their canonical form, while keeping other
	// width distinctions.
	t := runes.If(runes.In(unicode.Latin), width.Fold, nil)
	s, _, _ := transform.String(t, "アルアノリウ tech / アルアノリウ tech")
	fmt.Println(s)

	// Output:
	// アルアノリウ tech / アルアノリウ tech
}
示例#3
0
文件: image.go 项目: rahulg/jarvisbot
func dealWithYujian(rawQuery string) string {
	// We create a transformer that reduces all latin runes to their canonical form
	t := runes.If(runes.In(unicode.Latin), width.Fold, nil)
	rawQuery, _, _ = transform.String(t, rawQuery)

	if shawnTanRE.MatchString(rawQuery) {
		rawQuery = shawnRE.ReplaceAllLiteralString(rawQuery, "Yujian")
		rawQuery = TAN_RE.ReplaceAllLiteralString(rawQuery, "Yao")
	} else if tq := strings.Replace(rawQuery, " ", "", -1); shawnTanRE.MatchString(tq) {
		rawQuery = shawnRE.ReplaceAllLiteralString(tq, "Yujian")
		rawQuery = TAN_RE.ReplaceAllLiteralString(rawQuery, "Yao")
	}

	return rawQuery
}