charWidth returns the number of horizontal positions a character occupies, and is used to account for wide characters when displaying strings. In a broad sense, wide characters include East Asian Wide, East Asian Full-width, (when not in East Asian context) see http://unicode.org/reports/tr11/.
(r rune)
| 18 | // In a broad sense, wide characters include East Asian Wide, East Asian Full-width, |
| 19 | // (when not in East Asian context) see http://unicode.org/reports/tr11/. |
| 20 | func charWidth(r rune) int { |
| 21 | switch width.LookupRune(r).Kind() { |
| 22 | case width.EastAsianWide, width.EastAsianFullwidth: |
| 23 | return 2 |
| 24 | case width.Neutral, width.EastAsianAmbiguous, width.EastAsianNarrow, width.EastAsianHalfwidth: |
| 25 | return 1 |
| 26 | default: |
| 27 | return 1 |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // TruncateID returns a shorthand version of a string identifier for presentation, |
| 32 | // after trimming digest algorithm prefix (if any). |
no outgoing calls
no test coverage detected
searching dependent graphs…