public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(null); } var radicalStrokeCount = (UnicodeRadicalStrokeCount)value; var radical = UnicodeInfo.GetCjkRadicalInfo(radicalStrokeCount.Radical); return(radicalStrokeCount.IsSimplified ? radical.TraditionalRadicalCodePoint : radical.SimplifiedRadicalCodePoint); }
public void RadicalInfoShouldHaveExpectedResults() { var radical1 = UnicodeInfo.GetCjkRadicalInfo(1); Assert.False(radical1.HasSimplifiedForm); Assert.Equal(1, radical1.RadicalIndex); Assert.Equal('\u2F00', radical1.TraditionalRadicalCodePoint); Assert.Equal('\u4E00', radical1.TraditionalCharacterCodePoint); Assert.Equal('\u2F00', radical1.SimplifiedRadicalCodePoint); Assert.Equal('\u4E00', radical1.SimplifiedCharacterCodePoint); var radical214 = UnicodeInfo.GetCjkRadicalInfo(214); Assert.False(radical214.HasSimplifiedForm); Assert.Equal(214, radical214.RadicalIndex); Assert.Equal('\u2FD5', radical214.TraditionalRadicalCodePoint); Assert.Equal('\u9FA0', radical214.TraditionalCharacterCodePoint); Assert.Equal('\u2FD5', radical214.SimplifiedRadicalCodePoint); Assert.Equal('\u9FA0', radical214.SimplifiedCharacterCodePoint); Assert.Throws <IndexOutOfRangeException>(() => UnicodeInfo.GetCjkRadicalInfo(0)); Assert.Throws <IndexOutOfRangeException>(() => UnicodeInfo.GetCjkRadicalInfo(215)); }