CharacterCount returns the number of characters in a byte array Similar to utf8.RuneCount but for unicode characters
(b []byte)
| 67 | // CharacterCount returns the number of characters in a byte array |
| 68 | // Similar to utf8.RuneCount but for unicode characters |
| 69 | func CharacterCount(b []byte) int { |
| 70 | s := 0 |
| 71 | |
| 72 | for len(b) > 0 { |
| 73 | r, size := utf8.DecodeRune(b) |
| 74 | if !isMark(r) { |
| 75 | s++ |
| 76 | } |
| 77 | |
| 78 | b = b[size:] |
| 79 | } |
| 80 | |
| 81 | return s |
| 82 | } |
| 83 | |
| 84 | // CharacterCount returns the number of characters in a string |
| 85 | // Similar to utf8.RuneCountInString but for unicode characters |
no test coverage detected