Skip to content

Commit 9e0d53a

Browse files
committed
Update README.md
1 parent 7e014a2 commit 9e0d53a

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ go get github.com/clipperhouse/displaywidth
1010

1111
```go
1212
// StringWidth calculates the display width of a string
13-
// eastAsianWidth: when true, treat ambiguous width characters as wide (width 2)
14-
// strictEmojiNeutral: when true, use strict emoji width calculation (some emoji become width 1)
15-
func String(s string, eastAsianWidth bool, strictEmojiNeutral bool) int
13+
func String(s string) int
1614

1715
// BytesWidth calculates the display width of a []byte
18-
// eastAsianWidth: when true, treat ambiguous width characters as wide (width 2)
19-
// strictEmojiNeutral: when true, use strict emoji width calculation (some emoji become width 1)
20-
func Bytes(s []byte, eastAsianWidth bool, strictEmojiNeutral bool) int
16+
func Bytes(s []byte) int
2117
```
2218

2319
## Usage
@@ -32,15 +28,15 @@ import (
3228

3329
func main() {
3430
// Basic usage
35-
width := displaywidth.String("Hello, 世界!", false, false)
31+
width := displaywidth.String("Hello, 世界!")
3632
fmt.Println(width) // Output: 13
3733

3834
// With East Asian width mode
39-
width = displaywidth.String("café", true, false)
35+
width = displaywidth.String("café")
4036
fmt.Println(width) // Output: 4
4137

4238
// Using BytesWidth
43-
width = displaywidth.Bytes([]byte("🌍"), false, false)
39+
width = displaywidth.Bytes([]byte("🌍"))
4440
fmt.Println(width) // Output: 2
4541
}
4642
```
@@ -49,6 +45,9 @@ func main() {
4945

5046
This package implements the Unicode East Asian Width standard (UAX #11) and is intended to be compatible with `go-runewidth` and `wcwidth`. It operates on bytes without decoding runes for better performance.
5147

48+
There is also an `Options` type, to specify East Asian Width and Strict Emoji Neutral settings. If unspecified, the
49+
default is `EastAsianWidth: false, StrictEmojiNeutral: true`.
50+
5251
## Prior Art
5352

5453
[mattn/go-runewidth](https://github.com/mattn/go-runewidth), which is excellent and popular.

0 commit comments

Comments
 (0)