Last active
September 25, 2018 22:52
-
-
Save videlalvaro/29e7c71466bac663f3b86f1ce4dc9066 to your computer and use it in GitHub Desktop.
single_letter.go
This file contains 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 RuneCount(b []byte) int { | |
i, n := 0, 0 | |
for i < len(b) { | |
if b[i] < RuneSelf { | |
i++ | |
} else { | |
_, size := DecodeRune(b[i:]) | |
i += size | |
} | |
n++ | |
} | |
return n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment