lbcd/claimtrie/node/normalizer.go
Roy Lee 9080abc2c6 [lbry] claimtrie: import current snapshot
Sync to tip

Co-authored-by: Brannon King <countprimes@gmail.com>
2021-08-19 14:19:21 -04: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)
}