https://github.com/moznion/go-unicode-east-asian-width
Provides width properties of East Asian Characters
https://github.com/moznion/go-unicode-east-asian-width
Last synced: 8 months ago
JSON representation
Provides width properties of East Asian Characters
- Host: GitHub
- URL: https://github.com/moznion/go-unicode-east-asian-width
- Owner: moznion
- License: mit
- Created: 2014-06-22T10:12:45.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-22T12:43:13.000Z (almost 12 years ago)
- Last Synced: 2025-01-31T07:34:19.191Z (over 1 year ago)
- Language: Go
- Size: 148 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/moznion/go-unicode-east-asian-width)
# go-unicode-east-asian-width
Provides width properties of East Asian Characters.
This package is port of [Unicode::EastAsianWidth](http://search.cpan.org/~audreyt/Unicode-EastAsianWidth/lib/Unicode/EastAsianWidth.pm) from Perl to Go.
[https://godoc.org/github.com/moznion/go-unicode-east-asian-width](https://godoc.org/github.com/moznion/go-unicode-east-asian-width)
## Getting Started
```
go get github.com/moznion/go-unicode-east-asian-width
```
## Synopsis
```go
import (
"unicode"
"github.com/moznion/go-unicode-east-asian-width"
)
func main() {
eastasianwidth.IsFullwidth('δΈ') // true
eastasianwidth.IsHalfwidth('η') // false
eastasianwidth.IsHalfwidth('w') // true
unicode.Is(eastasianwidth.EastAsianWide, 'η¦
') // true
}
```
## Provided Variables
- `EastAsian bool`
EastAsian is the flag for ambiguous character.
If this flag is `true`, ambiguous characters are treated as full width.
Elsewise, ambiguous characters are treated as half width.
Default value is `false`.
- `EastAsianAmbiguous unicode.RangeTable`
- `EastAsianFullwidth unicode.RangeTable`
- `EastAsianHalfwidth unicode.RangeTable`
- `EastAsianNarrow unicode.RangeTable`
- `EastAsianNeutral unicode.RangeTable`
- `EastAsianWide unicode.RangeTable`
- `Fullwidth unicode.RangeTable`
- `Halfwidth unicode.RangeTable`
[RangeTable](http://golang.org/pkg/unicode/#RangeTable) for East Asian characters.
## Functions
- `func Fullwidth() map[string]*unicode.RangeTable`
Returns the map of [RangeTable](http://golang.org/pkg/unicode/#RangeTable) of full width East Asian characters.
- `func Halfwidth() map[string]*unicode.RangeTable`
Returns the map of [RangeTable](http://golang.org/pkg/unicode/#RangeTable) of half width East Asian characters.
- `func IsFullwidth(r rune) bool`
Reports whether the rune is in range of full width character of East Asian.
- `func IsHalfwidth(r rune) bool`
Reports whether the rune is in range of half width character of East Asian.
## See Also
- [unicode](http://golang.org/pkg/unicode/)
- [Unicode::EastAsianWidth](http://search.cpan.org/~audreyt/Unicode-EastAsianWidth/lib/Unicode/EastAsianWidth.pm)
## LICENSE
MIT