using System;
using NPinyin;
using System.Text;
namespace JiepeiWMS.Common.Helper
{
public class PinYinHelper
{
///
/// 汉字转小写全拼
///
///
///
public static string ConvertToAllSpell(string strChinese)
{
try
{
if (strChinese.Length != 0)
{
StringBuilder fullSpell = new StringBuilder();
for (int i = 0; i < strChinese.Length; i++)
{
var chr = strChinese[i];
fullSpell.Append(GetSpell(chr));
}
return fullSpell.ToString().ToLower();//转小写方法为 .ToLower()
}
}
catch (Exception e)
{
Console.WriteLine("出错!" + e.Message);
}
return string.Empty;
}
private static string GetSpell(char chr)
{
var coverchr = Pinyin.GetPinyin(chr);
return coverchr;
}
}
}