Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong width reported for some characters #36

Open
marcopaganini opened this issue Dec 28, 2019 · 2 comments
Open

Wrong width reported for some characters #36

marcopaganini opened this issue Dec 28, 2019 · 2 comments

Comments

@marcopaganini
Copy link

It appears that StringWidth reports the length of certain runes incorrectly. The problem seems to be centered around languages used primarily in India (Tamil, Telugu, and Hindi are examples).

Sample program that shows the problem:

package main

import (
	"fmt"
	"github.com/mattn/go-runewidth"
	"strings"
)

func main() {
	words := []string{
		"English",
		"हिन्द",
		"தமிழ்",
		"ไทย",
		"עברית",
	}

	for _, w := range words {
		max := 12 - runewidth.StringWidth(w)
		fmt.Printf("|%s%s|\n", w, strings.Repeat(" ", max))
	}
}

The output is shows the misalignment in the 2nd and 3rd rows (sorry, but pasting here won't work since Github seems to force "Liberation Mono" as the monospace font and this font appears to have its own issues). I've tried this on terminals, browsers, etc, always with similar results.

@mattn
Copy link
Owner

mattn commented Jan 9, 2020

As far as I tried to copy above into terminal, there are three letters in the string.

terminal7

So go-runewidth works fine (return 3 for the 2nd rows) for me.

@ghostsquad
Copy link

for reference, here's the go playground link, and the output screenshot

https://play.golang.org/p/iTnyFO4ML26

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants