func convert_utf8(s string) string { ic, err := iconv.Open("char", "UTF-8") if err != nil { return s } defer ic.Close() ret, _ := ic.Conv(s) return ret }
func main() { tocode := "SJIS" fromcode := "UTF-8" str := "これは漢字です。" //fmt.Printf("%s\n", str); cd := iconv.Open(tocode, fromcode) str = iconv.Iconv(cd, str) fmt.Printf("str='%s'\n", str) iconv.Close(cd) }