RuneCountInString in Go

Posted by GoDoc
Public (Editable by Users)

RuneCountInString is like RuneCount but its input is a string.

Go
Edit
package main

import (
    "fmt"
    "unicode/utf8"
)

func main() {
    str := "Hello, 世界"
    fmt.Println("bytes =", len(str))
    fmt.Println("runes =", utf8.RuneCountInString(str))
}