Created
August 16, 2016 09:22
-
-
Save derlin/76a0f3f5608475500c65cac68d3c60cc to your computer and use it in GitHub Desktop.
Properly decode an UTF-8 string in golang.
This file contains hidden or 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 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