Skip to content

Instantly share code, notes, and snippets.

@derlin
Created August 16, 2016 09:22
Show Gist options
  • Save derlin/76a0f3f5608475500c65cac68d3c60cc to your computer and use it in GitHub Desktop.
Save derlin/76a0f3f5608475500c65cac68d3c60cc to your computer and use it in GitHub Desktop.
Properly decode an UTF-8 string in golang.
func ToUtf8(to_decode string) string {
to_decode_buf := []byte(to_decode)
buf := make([]rune, len(to_decode_buf))
for i, b := range to_decode_buf {
buf[i] = rune(b)
}
return string(buf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment