Chinese numerals in Go
go get -u -v github.com/wzshiming/chinumeral
Chinese(1000).EncodeToString(Lower) // 一千
Chinese(1000).EncodeToString(Number) // 一〇〇〇
Chinese(1000).EncodeToString(Upper) // 壹仟
func TestChinese(t *testing.T) {
for i := Chinese(0); i != 1e6; i++ {
tmp, err := i.EncodeToString(Lower)
if err != nil {
t.Error(err)
}
var d Chinese
_, err = d.DecodeString(tmp)
if err != nil {
t.Error(err)
}
if i != d {
t.Fatal(uint64(i), tmp, uint64(d))
}
}
}
Pouch is licensed under the MIT License. See LICENSE for the full license text.