You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
613 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package PinYinUtil
import (
"dsBaseRpc/Utils/CommonUtil"
"fmt"
"github.com/cao-guang/pinyin"
)
func init(){
//这里是字典文件路径程序启动调用一次,载入缓存
var configIniFile = "./Config/pinyin.txt"
//判断文件不是存在
if !CommonUtil.Exists(configIniFile) {
configIniFile = "." + configIniFile
}
pinyin.LoadingPYFileName(configIniFile)
}
/**
功能:获取汉字的拼音
作者:黄海
时间2020-05-30
*/
func PinYin(hanzi string)string{
//默认造型: hanzipinyin
str1, err := pinyin.To_Py(hanzi, "", "")
if err != nil {
fmt.Println(err)
}
return str1
}