Files
zszq-trs/Framework/YLErp.Core/Helpers/PingYinHelper.cs
T
2024-05-09 14:06:26 +08:00

61 lines
1.6 KiB
C#

using TinyPinyin;
namespace YieldChain.Helpers
{
/// <summary>
/// 拼音帮助类
/// </summary>
public class PingYinHelper
{
/// <summary>
/// 汉字转拼音(注意:银行需要优化)
/// </summary>
public static string GetPinYin(string strChinese)
{
if (string.IsNullOrWhiteSpace(strChinese))
{
return string.Empty;
}
//注意:银行需要优化
//注意:英文字母不会转大写
return PinyinHelper.GetPinyin(strChinese);
}
/// <summary>
/// 汉字转拼音
/// </summary>
public static string GetPinYin(string strChinese, string separator)
{
if (string.IsNullOrWhiteSpace(strChinese))
{
return string.Empty;
}
if (separator is null)
{
separator = string.Empty;
}
//注意:银行需要优化
//注意:英文字母不会转大写
return PinyinHelper.GetPinyin(strChinese, separator);
}
/// <summary>
/// 汉字转拼音首字母
/// </summary>
public static string GetFirstPinYin(string strChinese)
{
if (string.IsNullOrWhiteSpace(strChinese))
{
return string.Empty;
}
//注意:银行需要优化
//注意:英文字母不会转大写
return PinyinHelper.GetPinyinInitials(strChinese);
}
}
}