Skip to content

jormin/tabwriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This is an extended version of text/tabwriter.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages