Created
December 6, 2015 01:54
-
-
Save yhirose/0c9f62941b1e878dd23b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func columnWidth(s string) int { | |
| runes := []rune(s) | |
| w := 0 | |
| for _, r := range runes { | |
| k := width.LookupRune(r).Kind() | |
| if k == width.EastAsianWide || k == width.EastAsianFullwidth { | |
| w = w + 2 | |
| } else { | |
| w = w + 1 | |
| } | |
| } | |
| return w | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment