1
0
mirror of https://github.com/fumiama/unibase2n.git synced 2026-06-27 15:30:31 +08:00

add base & pack

This commit is contained in:
源文雨
2022-09-30 20:15:57 +08:00
parent 4d15a66510
commit 35341dcad5
6 changed files with 119 additions and 0 deletions

29
pack.go Normal file
View File

@@ -0,0 +1,29 @@
package unibase2n
import "unsafe"
type Pack uint64
var (
Base16384 = newbasepack(0x4e00, 0x3d00, 14)
Base8192 = newbasepack(0xac00, 0xcc00, 13)
Base256 = newbasepack(0x1100, 0x0000, 4)
)
func newbasepack(off, til uint16, bit uint8) Pack {
b, err := NewBase(off, til, bit)
if err != nil {
panic(err)
}
return b.Pack()
}
func New(pack Pack) *Base {
b := &Base{}
*(*Pack)(unsafe.Pointer(b)) = pack
return b
}
func (b *Base) Pack() Pack {
return *(*Pack)(unsafe.Pointer(b))
}