Bugfixes.
This commit is contained in:
@@ -355,6 +355,54 @@ namespace UnicodeInformation.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetNameSuccessTest()
|
||||
{
|
||||
for (int i = 0; i <= 0x10FFFF; i++)
|
||||
{
|
||||
UnicodeInfo.GetName(i);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetDisplayTextSuccessTest()
|
||||
{
|
||||
for (int i = 0; i <= 0x10FFFF; i++)
|
||||
{
|
||||
UnicodeInfo.GetDisplayText(i);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetCategorySuccessTest()
|
||||
{
|
||||
for (int i = 0; i <= 0x10FFFF; i++)
|
||||
{
|
||||
UnicodeInfo.GetCategory(i);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetCharInfoSuccessTest()
|
||||
{
|
||||
for (int i = 0; i <= 0x10FFFF; i++)
|
||||
{
|
||||
UnicodeInfo.GetCharInfo(i);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetCharInfoCoherenceTest()
|
||||
{
|
||||
for (int i = 0; i <= 0x10FFFF; i++)
|
||||
{
|
||||
var charInfo = UnicodeInfo.GetCharInfo(i);
|
||||
|
||||
Assert.AreEqual(charInfo.Name, UnicodeInfo.GetName(i));
|
||||
Assert.AreEqual(charInfo.Category, UnicodeInfo.GetCategory(i));
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
[TestMethod]
|
||||
public void UnihanCodePointPackingTest()
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace System.Unicode
|
||||
|
||||
internal static bool IsHangul(int codePoint)
|
||||
{
|
||||
return codePoint >= SBase && codePoint <= SBase + SCount;
|
||||
return codePoint >= SBase && codePoint < SBase + SCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace System.Unicode
|
||||
internal UnicodeCharInfo(int codePoint, UnicodeCharacterData unicodeCharacterData, UnihanCharacterData unihanCharacterData, string block)
|
||||
{
|
||||
this.codePoint = codePoint;
|
||||
this.name = UnicodeInfo.GetName(codePoint, unicodeCharacterData);
|
||||
this.name = unicodeCharacterData != null ? UnicodeInfo.GetName(codePoint, unicodeCharacterData) : null;
|
||||
this.unicodeCharacterData = unicodeCharacterData;
|
||||
this.unihanCharacterData = unihanCharacterData;
|
||||
this.block = block;
|
||||
|
||||
@@ -435,6 +435,7 @@ namespace System.Unicode
|
||||
{
|
||||
if (codePoint <= 0x0020) return ((char)(0x2400 + codePoint)).ToString();
|
||||
else if (GetCategory(codePoint) == UnicodeCategory.NonSpacingMark) return "\u25CC" + char.ConvertFromUtf32(codePoint);
|
||||
else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) return "\xFFFD";
|
||||
else return char.ConvertFromUtf32(codePoint);
|
||||
}
|
||||
|
||||
@@ -448,7 +449,14 @@ namespace System.Unicode
|
||||
public static string GetName(int codePoint)
|
||||
{
|
||||
if (HangulInfo.IsHangul(codePoint)) return HangulInfo.GetHangulName((char)codePoint);
|
||||
else return GetName(codePoint, FindUnicodeCodePoint(codePoint));
|
||||
else return GetNameInternal(codePoint);
|
||||
}
|
||||
|
||||
private static string GetNameInternal(int codePoint)
|
||||
{
|
||||
var codePointInfo = FindUnicodeCodePoint(codePoint);
|
||||
|
||||
return codePointInfo != null ? GetName(codePoint, codePointInfo) : null;
|
||||
}
|
||||
|
||||
internal static string GetName(int codePoint, UnicodeCharacterData characterData)
|
||||
|
||||
Reference in New Issue
Block a user