pinyin.go
305 字节
package converter
import (
"github.com/mozillazg/go-pinyin"
"strings"
)
func ToPinYin(hans string, sep string) string {
a := pinyin.NewArgs()
tmp := pinyin.Pinyin(hans, a)
result := make([]string, 0)
for i := range tmp {
result = append(result, tmp[i]...)
}
return strings.Join(result, sep)
}