2017-06-25 02:36:38 +02:00
|
|
|
namespace System.Unicode
|
2014-11-15 00:58:03 +01:00
|
|
|
{
|
2017-06-25 02:36:38 +02:00
|
|
|
internal struct UnihanCharacterData
|
2014-11-15 00:58:03 +01:00
|
|
|
{
|
|
|
|
|
public readonly int CodePoint;
|
|
|
|
|
public readonly UnihanNumericType NumericType;
|
2014-11-15 11:50:43 +01:00
|
|
|
public readonly long NumericValue;
|
2014-11-24 02:36:09 +01:00
|
|
|
public readonly UnicodeRadicalStrokeCount[] UnicodeRadicalStrokeCounts;
|
2014-11-15 00:58:03 +01:00
|
|
|
public readonly string Definition;
|
|
|
|
|
public readonly string MandarinReading;
|
|
|
|
|
public readonly string CantoneseReading;
|
|
|
|
|
public readonly string JapaneseKunReading;
|
|
|
|
|
public readonly string JapaneseOnReading;
|
|
|
|
|
public readonly string KoreanReading;
|
|
|
|
|
public readonly string HangulReading;
|
|
|
|
|
public readonly string VietnameseReading;
|
|
|
|
|
public readonly string SimplifiedVariant;
|
|
|
|
|
public readonly string TraditionalVariant;
|
|
|
|
|
|
2014-11-15 11:50:43 +01:00
|
|
|
internal UnihanCharacterData
|
|
|
|
|
(
|
|
|
|
|
int codePoint,
|
|
|
|
|
UnihanNumericType numericType,
|
|
|
|
|
long numericValue,
|
2014-11-24 02:36:09 +01:00
|
|
|
UnicodeRadicalStrokeCount[] unicodeRadicalStrokeCounts,
|
2014-11-15 11:50:43 +01:00
|
|
|
string definition,
|
|
|
|
|
string mandarinReading,
|
|
|
|
|
string cantoneseReading,
|
|
|
|
|
string japaneseKunReading,
|
|
|
|
|
string japaneseOnReading,
|
|
|
|
|
string koreanReading,
|
|
|
|
|
string hangulReading,
|
|
|
|
|
string vietnameseReading,
|
|
|
|
|
string simplifiedVariant,
|
|
|
|
|
string traditionalVariant
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
CodePoint = codePoint;
|
|
|
|
|
NumericType = numericType;
|
|
|
|
|
NumericValue = numericValue;
|
2014-11-24 02:36:09 +01:00
|
|
|
UnicodeRadicalStrokeCounts = unicodeRadicalStrokeCounts;
|
2014-11-15 11:50:43 +01:00
|
|
|
Definition = definition;
|
|
|
|
|
MandarinReading = mandarinReading;
|
|
|
|
|
CantoneseReading = cantoneseReading;
|
|
|
|
|
JapaneseKunReading = japaneseKunReading;
|
|
|
|
|
JapaneseOnReading = japaneseOnReading;
|
|
|
|
|
KoreanReading = koreanReading;
|
|
|
|
|
HangulReading = hangulReading;
|
|
|
|
|
VietnameseReading = vietnameseReading;
|
|
|
|
|
SimplifiedVariant = simplifiedVariant;
|
|
|
|
|
TraditionalVariant = traditionalVariant;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-15 00:58:03 +01:00
|
|
|
internal static int PackCodePoint(int codePoint)
|
|
|
|
|
{
|
|
|
|
|
if (codePoint >= 0x3400)
|
|
|
|
|
{
|
|
|
|
|
if (codePoint < 0x4E00) return codePoint + 0x1E00;
|
|
|
|
|
else if (codePoint < 0xA000) return codePoint - 0x4E00;
|
|
|
|
|
else if (codePoint >= 0xF900 && codePoint < 0xFB00) return codePoint + 0xFD00;
|
|
|
|
|
else if (codePoint >= 0x20000)
|
|
|
|
|
{
|
|
|
|
|
if (codePoint < 0x2F800) return codePoint - 0x19400;
|
|
|
|
|
else if (codePoint < 0x30000) return codePoint - 0x10000;
|
|
|
|
|
}
|
2014-11-16 21:27:57 +01:00
|
|
|
}
|
2014-11-15 00:58:03 +01:00
|
|
|
|
2014-11-21 16:25:57 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(codePoint));
|
2014-11-16 21:27:57 +01:00
|
|
|
}
|
2014-11-15 00:58:03 +01:00
|
|
|
|
|
|
|
|
internal static int UnpackCodePoint(int packedCodePoint)
|
|
|
|
|
{
|
|
|
|
|
if (packedCodePoint >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (packedCodePoint < 0x05200) return packedCodePoint + 0x4E00;
|
|
|
|
|
else if (packedCodePoint < 0x06C00) return packedCodePoint - 0x1E00;
|
|
|
|
|
else if (packedCodePoint < 0x1F600) return packedCodePoint + 0x19400;
|
|
|
|
|
else if (packedCodePoint < 0x1F800) return packedCodePoint - 0xFD00;
|
|
|
|
|
else if (packedCodePoint < 0x20000) return packedCodePoint + 0x10000;
|
|
|
|
|
}
|
2014-11-21 16:25:57 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(packedCodePoint));
|
2014-11-15 00:58:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|