lbcd/claimtrie/node/normalizer.go
Roy Lee 424235655c [lbry] rework config and params
Ideally, network related params should be part of config, which is
passed down to the components to avoid references to global instances.

This commit is only halfway through as there are a couple of structs
that are too small to house the params and are still referencing
global variables. We'll rework that later.
2021-08-02 00:31:15 -07:00

30 lines
568 B
Go

package node
import (
"github.com/btcsuite/btcd/claimtrie/param"
"golang.org/x/text/cases"
"golang.org/x/text/unicode/norm"
)
//func init() {
// if cases.UnicodeVersion[:2] != "11" {
// panic("Wrong unicode version!")
// }
//}
var Normalize = normalizeGo
func NormalizeIfNecessary(name []byte, height int32) []byte {
if height < param.ActiveParams.NormalizedNameForkHeight {
return name
}
return Normalize(name)
}
var folder = cases.Fold()
func normalizeGo(value []byte) []byte {
normalized := norm.NFD.Bytes(value)
return folder.Bytes(normalized)
}