/// <summary> /// 检索指定字符的笔画数。 /// </summary> /// <param name="ch">指出需要识别的字符。</param> /// <returns>返回指定字符的笔画数。 如果字符不是有效值则返回-1。 </returns> public static short GetStrokeNumber(char ch) { if (!ChineseChar.IsValidChar(ch)) { return(-1); } CharUnit charUnit = ChineseChar.charDictionary.GetCharUnit(ch); return((short)charUnit.StrokeNumber); }
/// <summary> /// ChineseChar类的构造函数。 /// </summary> /// <param name="ch">指定的汉字字符。</param> public ChineseChar(char ch) { if (!ChineseChar.IsValidChar(ch)) { throw new NotSupportedException(AssemblyResource.CHARACTER_NOT_SUPPORTED); } this.chineseCharacter = ch; CharUnit charUnit = ChineseChar.charDictionary.GetCharUnit(ch); this.strokeNumber = (short)charUnit.StrokeNumber; this.pinyinCount = (short)charUnit.PinyinCount; this.isPolyphone = (charUnit.PinyinCount > 1); for (int i = 0; i < (int)this.pinyinCount; i++) { PinyinUnit pinYinUnitByIndex = ChineseChar.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[i]); this.pinyinList[i] = pinYinUnitByIndex.Pinyin; } }