Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wzshiming/chinumeral
Chinese numerals in Go
https://github.com/wzshiming/chinumeral
chinese chinese-numerals numeral numerals
Last synced: 8 days ago
JSON representation
Chinese numerals in Go
- Host: GitHub
- URL: https://github.com/wzshiming/chinumeral
- Owner: wzshiming
- License: mit
- Created: 2019-08-13T08:44:20.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T12:28:44.000Z (almost 5 years ago)
- Last Synced: 2024-06-21T10:58:36.590Z (5 months ago)
- Topics: chinese, chinese-numerals, numeral, numerals
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chinumeral
Chinese numerals in Go[![Go Report Card](https://goreportcard.com/badge/github.com/wzshiming/chinumeral)](https://goreportcard.com/report/github.com/wzshiming/chinumeral)
[![GoDoc](https://godoc.org/github.com/wzshiming/chinumeral?status.svg)](https://godoc.org/github.com/wzshiming/chinumeral)
[![GitHub license](https://img.shields.io/github/license/wzshiming/chinumeral.svg)](https://github.com/wzshiming/chinumeral/blob/master/LICENSE)
[![gocover.io](https://gocover.io/_badge/github.com/wzshiming/chinumeral)](https://gocover.io/github.com/wzshiming/chinumeral)## Install
``` shell
go get -u -v github.com/wzshiming/chinumeral
```## Example
``` golang
Chinese(1000).EncodeToString(Lower) // 一千
Chinese(1000).EncodeToString(Number) // 一〇〇〇
Chinese(1000).EncodeToString(Upper) // 壹仟
`````` golang
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))
}
}
}
```## License
Pouch is licensed under the MIT License. See [LICENSE](https://github.com/wzshiming/chinumeral/blob/master/LICENSE) for the full license text.