2021-07-06 18:39:56 -07:00
|
|
|
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 {
|
2021-07-31 22:15:14 -07:00
|
|
|
if height < param.ActiveParams.NormalizedNameForkHeight {
|
2021-07-06 18:39:56 -07:00
|
|
|
return name
|
|
|
|
}
|
|
|
|
return Normalize(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
var folder = cases.Fold()
|
|
|
|
|
|
|
|
func normalizeGo(value []byte) []byte {
|
|
|
|
|
|
|
|
normalized := norm.NFD.Bytes(value)
|
|
|
|
return folder.Bytes(normalized)
|
|
|
|
}
|