Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.66 KB

README.md

File metadata and controls

51 lines (37 loc) · 1.66 KB

tabwriter

Build Status Codecov GoDoc Go Report Card

This is an extended version of text/tabwriter.

Compared with the official version, it uses mattn/go-runewidth to calculate the variable width of unicode characters to adds more support to most (but not all) Chinese/Japanese/Korean characters, emojis, "fullwidth" Latin characters, etc.

Since the official version is already frozen,i create this extended version.

looking for more information with this issue text/tabwriter: character width #8273.

Usage

go get github.com/jormin/tabwriter

Changes

Official version
// Update the cell width.
func (b *Writer) updateWidth() {
	b.cell.width += utf8.RuneCount(b.buf[b.pos:])
	b.pos = len(b.buf)
}
This extended version
// Update the cell width.
func (b *Writer) updateWidth() {
	// b.cell.width += utf8.RuneCount(b.buf[b.pos:])
	b.cell.width += runewidth.StringWidth(string(b.buf[b.pos:]))
	b.pos = len(b.buf)
}

License

under the MIT License