常用函数记录
2019-05-08 本文已影响0人
右哼哼丨左哼哼
字符串编码转换函数:
import (
"github.com/axgle/mahonia"
)
func UseNewEncoder(src string,oldEncoder string,newEncoder string) string{
srcDecoder := mahonia.NewDecoder(oldEncoder)
desDecoder := mahonia.NewDecoder(newEncoder)
resStr:= srcDecoder.ConvertString(src)
_, resBytes, _ := desDecoder .Translate([]byte(resStr), true)
return string(resBytes)
}