ayanmw
ayanmw
既然是转换, 那你就应该使用Encoder, 把你的 ConverToString 修改一下就可以了: ```golang func ConvertToString(src string, srcCode string, tagCode string) string { srcCoder := convlib.NewDecoder(srcCode) srcResult := srcCoder.ConvertString(src) //fmt.Println("srcResult["+srcCode+"]=", src, " => ", srcResult) tagCoder := convlib.NewEncoder(tagCode)...
其实可以优化一下, 也就是 如果其中有一方是 UTF8 , 那么则不需要转换 ,反正 UTF8 转UTF8 是一样的。 如果srcCode desCode 都不是 UTF8 , 其实会使用UTF8 作为中间层,转换。
looks not , you can see RegisterCharset func in the code, it support "EUC-JP" 。 It can extend any characterset with `RegisterCharset(...)`
>  > > if I do enc := ma.NewEncoder("gb18030") first and then print with enc.ConvertString(file1.Name) > I would get Chinese garbled. > > But if I just do ma.NewDecoder("gb18030").ConvertString(file1.Name)...