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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/// <summary>
///找到中文短语的拼音首字母。
/// </summary>
/// <param name="wStrChs">中文短语</param>
/// <param name="strResult">拼音首字母,存在多音字时以,分隔。</param>
/// <remarks>如:西单,将返回XD,XS,XC。</remarks>
static string ChineseFirstPY =
if (j >= 0)
{Biblioteka Baidu
strResult = MultiPinyin.Substring(i + nUniCode, j - i - nUniCode);
}
}
return;
}
/// <summary>
///车站信息
/// </summary>
public Dictionary<string, LocationDetails> dicStationInfo = new Dictionary<string, LocationDetails>();
GetSpellByChs(wStrChs[i], ref strBuffer);
if (strBuffer.Length > 0)
{
if (strResult != string.Empty)
{
string[] strs = strResult.Split(',');
strResult = "";
nUniCode = chUniCode.Length;
i = MultiPinyin.IndexOf(chUniCode);
if (i < 0)
{ strResult = ChineseFirstPY[uni - 19968].ToString(); }
else
{
j = MultiPinyin.IndexOf(",", i);
public static void GetFirstLetter(string wStrChs, ref string strResult)
{
strResult = "";
string strBuffer = "";
for (int i = 0; i < wStrChs.Length; i++)
{
{
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);
{
strResult += strBuffer[j] + ",";
}
}
if (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++)
/// </summary>
/// <param name="chChs">中文单字</param>
/// <param name="strResult">拼音首字母,多音字时返回多个拼音字母</param>
/// <remarks>如:单,将返回DSC。</remarks>
public static void GetSpellByChs(char chChs, ref string strResult)
相关文档
最新文档