Go: Convert byte slice (array) to string

Converting a slice of bytes to a string yields a string whose bytes are the elements of the slice:

b := []byte{'a', 'b', 'c', '\xe6', '\x97', '\xa5'}
s := string(b)
fmt.Println(s)
// Output: abc日

Comments

Be the first to comment!