lbcd/claimtrie/normalization/normalizer.go
2021-08-19 17:51:07 -04:00

22 lines
574 B
Go

package normalization
import (
"github.com/btcsuite/btcd/claimtrie/param"
"golang.org/x/text/unicode/norm"
)
var Normalize = normalizeGo
func NormalizeIfNecessary(name []byte, height int32) []byte {
if height < param.ActiveParams.NormalizedNameForkHeight {
return name
}
return Normalize(name)
}
func normalizeGo(value []byte) []byte {
normalized := norm.NFD.Bytes(value) // may need to hard-code the version on this
// not using x/text/cases because it does too good of a job; it seems to use v14 tables even when it claims v13
return CaseFold(normalized)
}