runewidth

package
v1.4.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2016 License: GPL-3.0 Imports: 3 Imported by: 0

README

go-runewidth
============

[![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth)
[![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD)

Provides functions to get fixed width of the character or string.

Usage
-----

```go
runewidth.StringWidth("つのだ☆HIRO") == 12
```


Author
------

Yasuhiro Matsumoto

License
-------

under the MIT License: http://mattn.mit-license.org/2013

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCondition = &Condition{EastAsianWidth}
View Source
var EastAsianWidth = IsEastAsian()

Functions

func FillLeft added in v1.4.0

func FillLeft(s string, w int) string

func FillRight added in v1.4.0

func FillRight(s string, w int) string

func IsAmbiguousWidth

func IsAmbiguousWidth(r rune) bool

IsAmbiguousWidth returns whether is ambiguous width or not.

func IsEastAsian

func IsEastAsian() bool

func IsNeutralWidth

func IsNeutralWidth(r rune) bool

IsAmbiguousWidth returns whether is ambiguous width or not.

func RuneWidth

func RuneWidth(r rune) int

RuneWidth returns the number of cells in r. See http://www.unicode.org/reports/tr11/

func StringWidth

func StringWidth(s string) (width int)

func Truncate

func Truncate(s string, w int, tail string) string

func Wrap added in v1.4.0

func Wrap(s string, w int) string

Types

type Condition

type Condition struct {
	EastAsianWidth bool
}

func NewCondition

func NewCondition() *Condition

func (*Condition) FillLeft added in v1.4.0

func (c *Condition) FillLeft(s string, w int) string

func (*Condition) FillRight added in v1.4.0

func (c *Condition) FillRight(s string, w int) string

func (*Condition) RuneWidth

func (c *Condition) RuneWidth(r rune) int

RuneWidth returns the number of cells in r. See http://www.unicode.org/reports/tr11/

func (*Condition) StringWidth

func (c *Condition) StringWidth(s string) (width int)

func (*Condition) Truncate

func (c *Condition) Truncate(s string, w int, tail string) string

func (*Condition) Wrap added in v1.4.0

func (c *Condition) Wrap(s string, w int) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL