Beispiel #1
0
func ExampleMap() {
	replaceHyphens := runes.Map(func(r rune) rune {
		if unicode.Is(unicode.Hyphen, r) {
			return '|'
		}
		return r
	})
	s, _, _ := transform.String(replaceHyphens, "a-b‐c⸗d﹣e")
	fmt.Println(s)

	// Output:
	// a|b|c|d|e
}
Beispiel #2
0
			return &nickAdditionalMapping{}
		}),
		IgnoreCase,
		Norm(norm.NFKC),
		DisallowEmpty,
	)
	usernameCaseMap = NewIdentifier(
		FoldWidth,
		LowerCase(),
		Norm(norm.NFC),
		BidiRule,
	)
	usernameNoCaseMap = NewIdentifier(
		FoldWidth,
		Norm(norm.NFC),
		BidiRule,
	)
	opaquestring = NewFreeform(
		AdditionalMapping(func() transform.Transformer {
			return runes.Map(func(r rune) rune {
				if unicode.Is(unicode.Zs, r) {
					return ' '
				}
				return r
			})
		}),
		Norm(norm.NFC),
		DisallowEmpty,
	)
)
Beispiel #3
0
		Norm(norm.NFKC),
		DisallowEmpty,
	)
	usernameCaseMap = NewIdentifier(
		FoldWidth,
		LowerCase(),
		Norm(norm.NFC),
		BidiRule,
	)
	usernameNoCaseMap = NewIdentifier(
		FoldWidth,
		Norm(norm.NFC),
		BidiRule,
	)
	opaquestring = NewFreeform(
		AdditionalMapping(func() transform.Transformer {
			return mapSpaces
		}),
		Norm(norm.NFC),
		DisallowEmpty,
	)
)

// mapSpaces is a shared value of a runes.Map transformer.
var mapSpaces transform.Transformer = runes.Map(func(r rune) rune {
	if unicode.Is(unicode.Zs, r) {
		return ' '
	}
	return r
})