ccaa6dd816
Sync to tip Co-authored-by: Brannon King <countprimes@gmail.com>
30 lines
555 B
Go
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)
|
|
}
|