Skip to content

Wrong width reported for some characters #36

@marcopaganini

Description

@marcopaganini

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions