当前位置:文档之家› 汉字与首字母相互转换:输入汉字拼音首字母,自动识别汉字; 输入汉字,自动获取首字母;

汉字与首字母相互转换:输入汉字拼音首字母,自动识别汉字; 输入汉字,自动获取首字母;

public static void GetFirstLetter(string wStrChs, ref string strResult)
{
strResult = "";
string strBuffer = "";
for (int i = 0; i < wStrChs.Length; i++)
{
{
strResult += strBuffer[j] + &#(strResult != string.Empty)
strResult = strResult.Substring(0, strResult.Length - 1);
}
}
}
/// <summary>
///返回中文单字的拼音首字母。
for (int j = 0; j < strs.Length; j++)
{
for (int k = 0; k < strBuffer.Length; k++)
{
strResult += strs[j] + strBuffer[k].ToString() + ",";
}
}
}
else
{
for (int j = 0; j < strBuffer.Length; j++)
if (j >= 0)
{
strResult = MultiPinyin.Substring(i + nUniCode, j - i - nUniCode);
}
}
return;
}
/// <summary>
///车站信息
/// </summary>
public Dictionary<string, LocationDetails> dicStationInfo = new Dictionary<string, LocationDetails>();
{
string chUniCode;
int nUniCode;
int uni, i, j;
strResult = string.Empty;
uni = (UInt16)chChs;
if (uni > 40869 || uni < 19968)
return;
chUniCode = string.Format("{0}:", uni);
nUniCode = chUniCode.Length;
i = MultiPinyin.IndexOf(chUniCode);
if (i < 0)
{ strResult = ChineseFirstPY[uni - 19968].ToString(); }
else
{
j = MultiPinyin.IndexOf(",", i);
static string ChineseFirstPY =
/// <summary>
///找到中文短语的拼音首字母。
/// </summary>
/// <param name="wStrChs">中文短语</param>
/// <param name="strResult">拼音首字母,存在多音字时以,分隔。</param>
/// <remarks>如:西单,将返回XD,XS,XC。</remarks>
GetSpellByChs(wStrChs[i], ref strBuffer);
if (strBuffer.Length > 0)
{
if (strResult != string.Empty)
{
string[] strs = strResult.Split(',');
strResult = "";
/// </summary>
/// <param name="chChs">中文单字</param>
/// <param name="strResult">拼音首字母,多音字时返回多个拼音字母</param>
/// <remarks>如:单,将返回DSC。</remarks>
public static void GetSpellByChs(char chChs, ref string strResult)
相关主题