go-runewidth icon indicating copy to clipboard operation
go-runewidth copied to clipboard

fix runewidth_table.go

Open gdrens opened this issue 3 years ago • 4 comments

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

gdrens avatar Nov 26 '21 05:11 gdrens

Which standard is defined for that?

mattn avatar Nov 26 '21 05:11 mattn

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?

gdrens avatar Nov 26 '21 10:11 gdrens

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

mattn avatar Nov 27 '21 16:11 mattn

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. *

gdrens avatar Nov 28 '21 03:11 gdrens