Created
September 25, 2018 22:53
-
-
Save videlalvaro/bcdf07ae3e1dfa6b39226a22f2bbd7dd to your computer and use it in GitHub Desktop.
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(buffer []byte) int { | |
index, count := 0, 0 | |
for index < len(buffer) { | |
if buffer[index] < RuneSelf { | |
index++ | |
} else { | |
_, size := DecodeRune(buffer[index:]) | |
index += size | |
} | |
count++ | |
} | |
return count | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment