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

Co-authored-by: Brannon King <countprimes@gmail.com>
2021-07-08 10:41:12 -07:00

30 lines
555 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.NormalizedNameForkHeight {
return name
}
return Normalize(name)
}
var folder = cases.Fold()
func normalizeGo(value []byte) []byte {
normalized := norm.NFD.Bytes(value)
return folder.Bytes(normalized)
}