Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created September 25, 2018 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlalvaro/bcdf07ae3e1dfa6b39226a22f2bbd7dd to your computer and use it in GitHub Desktop.
Save videlalvaro/bcdf07ae3e1dfa6b39226a22f2bbd7dd to your computer and use it in GitHub Desktop.
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