Skip to content

Instantly share code, notes, and snippets.

@godriccao
Last active June 14, 2018 06:15
Show Gist options
  • Save godriccao/c8776944f8359f6a793604d84e50ab08 to your computer and use it in GitHub Desktop.
Save godriccao/c8776944f8359f6a793604d84e50ab08 to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/text/width"
"fmt"
)
func main() {
str := []string{
"◎",
"全",
"1",
"F",
"ナ",
}
for _, s := range(str) {
for _, r := range(s) {
p := width.LookupRune(r)
fmt.Printf("Kind:%s(%d)\t Rune:%s\n",p.Kind(), p.Kind(), string(r))
}
}
}
// Kind:EastAsianAmbiguous(1) Rune:◎
// Kind:EastAsianWide(2) Rune:全
// Kind:EastAsianNarrow(3) Rune:1
// Kind:EastAsianFullwidth(4) Rune:F
// Kind:EastAsianHalfwidth(5) Rune:ナ
// Kind:EastAsianWide(2) Rune:ナ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment