tablewriter icon indicating copy to clipboard operation
tablewriter copied to clipboard

Wrong table formatting when using warning unicode symbol

Open TSkrebe opened this issue 5 years ago • 3 comments

Table is incorrectly formatted when warning symbol is used ⚠️(U+26A0). Other symbols such as ✅ (U+2705) are not affected. The problem didn't exist with github.com/mattn/go-runewidth v0.0.3

package main

import (
	"os"

	"github.com/olekukonko/tablewriter"
)

func main() {
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Test collumn", "Unicode"})
	table.Append([]string{"test", ""})
	table.Append([]string{"test", "⚠️"})
	table.Render()
}

go.mod

module table

go 1.12

require (
	github.com/mattn/go-runewidth v0.0.4 // indirect
	github.com/olekukonko/tablewriter v0.0.1
)

go.sum

github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=

output:

+--------------+---------+
| TEST COLLUMN | UNICODE |
+--------------+---------+
| test         |         |
| test         | ⚠️      |
+--------------+---------+

TSkrebe avatar Sep 06 '19 09:09 TSkrebe

tablewriter is using go-runewidth to calculate the width of string. This issue might be related to https://github.com/mattn/go-runewidth/issues/28.

upwell avatar Apr 15 '20 03:04 upwell

tablewriter is using go-runewidth to calculate the width of string. This issue might be related to mattn/go-runewidth#28.

looks like that's fixed would you be able to upgrade the dependency on this project? @olekukonko

harshavardhana avatar Jun 10 '22 05:06 harshavardhana

https://github.com/olekukonko/tablewriter/commit/9627d02c9655319c8e1e36b8ef7f18d15c87d974 looks like this is already updated and this issue should be closed.

harshavardhana avatar Jun 10 '22 05:06 harshavardhana