mattn / go-runewidth

wcwidth for golang
MIT License
609 stars 94 forks source link

fix runewidth_table.go #57

Open gdrens opened 2 years ago

gdrens commented 2 years ago

If LANG="zh_CN.UTF8",the Tabs(0x2500-0x257F) will return 2,but should return 1

mattn commented 2 years ago

Which standard is defined for that?

gdrens commented 2 years ago

I use rxvt, this terminal is VT100 standard, if you mean to ask this. unicode (0x2500-0x257F) only occupies one character position in my terminal, but I have not tested it on more terminal standards

code:

package main

import ( "fmt" "syscall" "unsafe" )

func main() { var termDim [4]uint16 syscall.Syscall6(syscall.SYS_IOCTL, uintptr(0), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&termDim)), 0, 0, 0)

fmt.Println(termDim[1], termDim[0])
j := 0
for i := 0x2500; i < 0x2580; i++ {
    fmt.Printf("%c", i)
    j++
}
fmt.Println()
fmt.Println(j)

}

On Thu, Nov 25, 2021 at 09:43:51PM -0800, mattn wrote:

Which standard is defined for that?

mattn commented 2 years ago

That is not a specification. go-runewidth generate tables from Unicode specification.

gdrens commented 2 years ago

Yes, I know, but in the unicode specification, the screen width occupied by the tab character 0x2500~0x257F should be 1, but now the returned value is 2

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. *