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

30 lines
628 B
C#

using hyjiacan.py4n;
namespace DS.Module.Core;
/// <summary>
/// 汉字转拼音
/// </summary>
public class PinYinUtil
{
/// <summary>
/// 汉字转拼音首字母
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static string GetFristLetter(string str)
{
string ret = "";
char[] stra = str.ToCharArray();
foreach (char c in stra)
{
if (PinyinUtil.IsHanzi(c))
ret += Pinyin4Net.GetFirstPinyin(c).ToUpper().Substring(0, 1);
else
ret += c;
}
return ret;
}
}