Added XML documentation on some members.
This commit is contained in:
@@ -7,53 +7,100 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Represents possible values for the Bidi_Class unicode property.</summary>
|
||||
public enum BidirectionalClass : byte
|
||||
{
|
||||
[ValueName("L"), ValueName("Left_To_Right"), Display(Name = "Left_To_Right", Description = "any strong left-to-right character")]
|
||||
/// <summary>Represents the value Left_To_Right.</summary>
|
||||
/// <remarks>Any strong left-to-right character.</remarks>
|
||||
[ValueName("L"), ValueName("Left_To_Right"), Display(Name = "Left_To_Right", Description = "Any strong left-to-right character.")]
|
||||
LeftToRight,
|
||||
[ValueName("R"), ValueName("Right_To_Left"), Display(Name = "Right_To_Left", Description = "any strong right-to-left (non-Arabic-type) character")]
|
||||
/// <summary>Represents the value Right_To_Left.</summary>
|
||||
/// <remarks>Any strong right-to-left (non-Arabic-type) character.</remarks>
|
||||
[ValueName("R"), ValueName("Right_To_Left"), Display(Name = "Right_To_Left", Description = "Any strong right-to-left (non-Arabic-type) character.")]
|
||||
RightToLeft,
|
||||
[ValueName("AL"), ValueName("Arabic_Letter"), Display(Name = "Arabic_Letter", Description = "any strong right-to-left (Arabic-type) character")]
|
||||
/// <summary>Represents the value Arabic_Letter.</summary>
|
||||
/// <remarks>Any strong right-to-left (Arabic-type) character.</remarks>
|
||||
[ValueName("AL"), ValueName("Arabic_Letter"), Display(Name = "Arabic_Letter", Description = "Any strong right-to-left (Arabic-type) character.")]
|
||||
ArabicLetter,
|
||||
[ValueName("EN"), ValueName("European_Number"), Display(Name = "European_Number", Description = "any ASCII digit or Eastern Arabic-Indic digit")]
|
||||
/// <summary>Represents the value European_Number.</summary>
|
||||
/// <remarks>Any ASCII digit or Eastern Arabic-Indic digit.</remarks>
|
||||
[ValueName("EN"), ValueName("European_Number"), Display(Name = "European_Number", Description = "Any ASCII digit or Eastern Arabic-Indic digit.")]
|
||||
EuropeanNumber,
|
||||
[ValueName("ES"), ValueName("European_Separator"), Display(Name = "European_Separator", Description = "plus and minus signs")]
|
||||
/// <summary>Represents the value European_Separator.</summary>
|
||||
/// <remarks>Plus and minus signs.</remarks>
|
||||
[ValueName("ES"), ValueName("European_Separator"), Display(Name = "European_Separator", Description = "Plus and minus signs.")]
|
||||
EuropeanSeparator,
|
||||
[ValueName("ET"), ValueName("European_Terminator"), Display(Name = "European_Terminator", Description = "a terminator in a numeric format context, includes currency signs")]
|
||||
/// <summary>Represents the value European_Terminator.</summary>
|
||||
/// <remarks>A terminator in a numeric format context, includes currency signs.</remarks>
|
||||
[ValueName("ET"), ValueName("European_Terminator"), Display(Name = "European_Terminator", Description = "A terminator in a numeric format context, includes currency signs.")]
|
||||
EuropeanTerminator,
|
||||
[ValueName("AN"), ValueName("Arabic_Number"), Display(Name = "Arabic_Number", Description = "any Arabic-Indic digit")]
|
||||
/// <summary>Represents the value Arabic_Number.</summary>
|
||||
/// <remarks>Any Arabic-Indic digit.</remarks>
|
||||
[ValueName("AN"), ValueName("Arabic_Number"), Display(Name = "Arabic_Number", Description = "Any Arabic-Indic digit.")]
|
||||
ArabicNumber,
|
||||
[ValueName("CS"), ValueName("Common_Separator"), Display(Name = "Common_Separator", Description = "commas, colons, and slashes")]
|
||||
/// <summary>Represents the value Common_Separator.</summary>
|
||||
/// <remarks>Commas, colons, and slashes.</remarks>
|
||||
[ValueName("CS"), ValueName("Common_Separator"), Display(Name = "Common_Separator", Description = "Commas, colons, and slashes.")]
|
||||
CommonSeparator,
|
||||
[ValueName("NSM"), ValueName("Nonspacing_Mark"), Display(Name = "Nonspacing_Mark", Description = "any nonspacing mark")]
|
||||
/// <summary>Represents the value Nonspacing_Mark.</summary>
|
||||
/// <remarks>Any nonspacing mark.</remarks>
|
||||
[ValueName("NSM"), ValueName("Nonspacing_Mark"), Display(Name = "Nonspacing_Mark", Description = "Any nonspacing mark.")]
|
||||
NonSpacingMark,
|
||||
[ValueName("BN"), ValueName("Boundary_Neutral"), Display(Name = "Boundary_Neutral", Description = "most format characters, control codes, or noncharacters")]
|
||||
/// <summary>Represents the value Boundary_Neutral.</summary>
|
||||
/// <remarks>Most format characters, control codes, or noncharacters.</remarks>
|
||||
[ValueName("BN"), ValueName("Boundary_Neutral"), Display(Name = "Boundary_Neutral", Description = "Most format characters, control codes, or noncharacters.")]
|
||||
BoundaryNeutral,
|
||||
[ValueName("B"), ValueName("Paragraph_Separator"), Display(Name = "Paragraph_Separator", Description = "various newline characters")]
|
||||
/// <summary>Represents the value Paragraph_Separator.</summary>
|
||||
/// <remarks>Various newline characters.</remarks>
|
||||
[ValueName("B"), ValueName("Paragraph_Separator"), Display(Name = "Paragraph_Separator", Description = "Various newline characters.")]
|
||||
ParagraphSeparator,
|
||||
[ValueName("S"), ValueName("Segment_Separator"), Display(Name = "Segment_Separator", Description = "various segment-related control codes")]
|
||||
/// <summary>Represents the value Segment_Separator.</summary>
|
||||
/// <remarks>Various segment-related control codes.</remarks>
|
||||
[ValueName("S"), ValueName("Segment_Separator"), Display(Name = "Segment_Separator", Description = "Various segment-related control codes.")]
|
||||
SegmentSeparator,
|
||||
[ValueName("WS"), ValueName("White_Space"), Display(Name = "White_Space", Description = "spaces")]
|
||||
/// <summary>Represents the value White_Space.</summary>
|
||||
/// <remarks>Spaces.</remarks>
|
||||
[ValueName("WS"), ValueName("White_Space"), Display(Name = "White_Space", Description = "Spaces.")]
|
||||
WhiteSpace,
|
||||
[ValueName("ON"), ValueName("Other_Neutral"), Display(Name = "Other_Neutral", Description = "most other symbols and punctuation marks")]
|
||||
/// <summary>Represents the value Other_Neutral.</summary>
|
||||
/// <remarks>Most other symbols and punctuation marks.</remarks>
|
||||
[ValueName("ON"), ValueName("Other_Neutral"), Display(Name = "Other_Neutral", Description = "Most other symbols and punctuation marks.")]
|
||||
OtherNeutral,
|
||||
[ValueName("LRE"), ValueName("Left_To_Right_Embedding"), Display(Name = "Left_To_Right_Embedding", Description = "U+202A: the LR embedding control")]
|
||||
/// <summary>Represents the value Left_To_Right_Embedding.</summary>
|
||||
/// <remarks>U+202A: the LR embedding control.</remarks>
|
||||
[ValueName("LRE"), ValueName("Left_To_Right_Embedding"), Display(Name = "Left_To_Right_Embedding", Description = "U+202A: the LR embedding control.")]
|
||||
LeftToRightEmbedding,
|
||||
[ValueName("LRO"), ValueName("Left_To_Right_Override"), Display(Name = "Left_To_Right_Override", Description = "U+202D: the LR override control")]
|
||||
/// <summary>Represents the value Left_To_Right_Override.</summary>
|
||||
/// <remarks>U+202D: the LR override control.</remarks>
|
||||
[ValueName("LRO"), ValueName("Left_To_Right_Override"), Display(Name = "Left_To_Right_Override", Description = "U+202D: the LR override control.")]
|
||||
LeftToRightOverride,
|
||||
[ValueName("RLE"), ValueName("Right_To_Left_Embedding"), Display(Name = "Right_To_Left_Embedding", Description = "U+202B: the RL embedding control")]
|
||||
/// <summary>Represents the value Right_To_Left_Embedding.</summary>
|
||||
/// <remarks>U+202B: the RL embedding control.</remarks>
|
||||
[ValueName("RLE"), ValueName("Right_To_Left_Embedding"), Display(Name = "Right_To_Left_Embedding", Description = "U+202B: the RL embedding control.")]
|
||||
RightToLeftEmbedding,
|
||||
[ValueName("RLO"), ValueName("Right_To_Left_Override"), Display(Name = "Right_To_Left_Override", Description = "U+202E: the RL override control")]
|
||||
/// <summary>Represents the value Right_To_Left_Override.</summary>
|
||||
/// <remarks>U+202E: the RL override control.</remarks>
|
||||
[ValueName("RLO"), ValueName("Right_To_Left_Override"), Display(Name = "Right_To_Left_Override", Description = "U+202E: the RL override control.")]
|
||||
RightToLeftOverride,
|
||||
[ValueName("PDF"), ValueName("Pop_Directional_Format"), Display(Name = "Pop_Directional_Format", Description = "U+202C: terminates an embedding or override control")]
|
||||
/// <summary>Represents the value Pop_Directional_Format.</summary>
|
||||
/// <remarks>U+202C: terminates an embedding or override control.</remarks>
|
||||
[ValueName("PDF"), ValueName("Pop_Directional_Format"), Display(Name = "Pop_Directional_Format", Description = "U+202C: terminates an embedding or override control.")]
|
||||
PopDirectionalFormat,
|
||||
[ValueName("LRI"), ValueName("Left_To_Right_Isolate"), Display(Name = "Left_To_Right_Isolate", Description = "U+2066: the LR isolate control")]
|
||||
/// <summary>Represents the value Left_To_Right_Isolate.</summary>
|
||||
/// <remarks>U+2066: the LR isolate control.</remarks>
|
||||
[ValueName("LRI"), ValueName("Left_To_Right_Isolate"), Display(Name = "Left_To_Right_Isolate", Description = "U+2066: the LR isolate control.")]
|
||||
LeftToRightIsolate,
|
||||
[ValueName("RLI"), ValueName("Right_To_Left_Isolate"), Display(Name = "Right_To_Left_Isolate", Description = "U+2067: the RL isolate control")]
|
||||
/// <summary>Represents the value Right_To_Left_Isolate.</summary>
|
||||
/// <remarks>U+2067: the RL isolate control.</remarks>
|
||||
[ValueName("RLI"), ValueName("Right_To_Left_Isolate"), Display(Name = "Right_To_Left_Isolate", Description = "U+2067: the RL isolate control.")]
|
||||
RightToLeftIsolate,
|
||||
[ValueName("FSI"), ValueName("First_Strong_Isolate"), Display(Name = "First_Strong_Isolate", Description = "U+2068: the first strong isolate control")]
|
||||
/// <summary>Represents the value First_Strong_Isolate.</summary>
|
||||
/// <remarks>U+2068: the first strong isolate control.</remarks>
|
||||
[ValueName("FSI"), ValueName("First_Strong_Isolate"), Display(Name = "First_Strong_Isolate", Description = "U+2068: the first strong isolate control.")]
|
||||
FirstStrongIsolate,
|
||||
[ValueName("PDI"), ValueName("Pop_Directional_Isolate"), Display(Name = "Pop_Directional_Isolate", Description = "U+2069: terminates an isolate control")]
|
||||
/// <summary>Represents the value Pop_Directional_Isolate.</summary>
|
||||
/// <remarks>U+2069: terminates an isolate control.</remarks>
|
||||
[ValueName("PDI"), ValueName("Pop_Directional_Isolate"), Display(Name = "Pop_Directional_Isolate", Description = "U+2069: terminates an isolate control.")]
|
||||
PopDirectionalIsolate,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,18 +6,35 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Provides information on a specific CJK radical.</summary>
|
||||
public struct CjkRadicalInfo
|
||||
{
|
||||
private readonly byte radicalIndex;
|
||||
private readonly CjkRadicalData radicalData;
|
||||
|
||||
/// <summary>The index of the radical in the Kangxi dictionary.</summary>
|
||||
/// <remarks>There are 214 radicals, numbered from 1 to 214.</remarks>
|
||||
public byte RadicalIndex { get { return radicalIndex; } }
|
||||
|
||||
/// <summary>Gets a code point representing the CJK radical in its traditional form.</summary>
|
||||
public char TraditionalRadicalCodePoint { get { return radicalData.TraditionalRadicalCodePoint; } }
|
||||
/// <summary>Gets the code point of a traditional character composed only of the CJK radical.</summary>
|
||||
/// <remarks>
|
||||
/// Usually, the glyph of this code point will be the same as the one used for <see cref="TraditionalRadicalCodePoint"/>.
|
||||
/// However, the code point returned will have a meaning associated, contrary to the one returned by <see cref="TraditionalRadicalCodePoint"/>, which only represents the radical.
|
||||
/// </remarks>
|
||||
public char TraditionalCharacterCodePoint { get { return radicalData.TraditionalCharacterCodePoint; } }
|
||||
/// <summary>Gets a code point representing the CJK radical in its simplified form, which may be the same as the traditional form.</summary>
|
||||
/// <remarks>Most of the time, the value returned will be the same as <see cref="TraditionalRadicalCodePoint"/>.</remarks>
|
||||
public char SimplifiedRadicalCodePoint { get { return radicalData.SimplifiedRadicalCodePoint; } }
|
||||
/// <summary>Gets the code point of a simplified character composed only of the CJK radical.</summary>
|
||||
/// <remarks>
|
||||
/// Usually, the glyph of this code point will be the same as the one used for <see cref="SimplifiedRadicalCodePoint"/>.
|
||||
/// However, the code point returned will have a meaning associated, contrary to the one returned by <see cref="SimplifiedRadicalCodePoint"/>, which only represents the radical.
|
||||
/// </remarks>
|
||||
public char SimplifiedCharacterCodePoint { get { return radicalData.SimplifiedCharacterCodePoint; } }
|
||||
|
||||
/// <summary>Gets a value indicating whether a simplified form exists for the given radical.</summary>
|
||||
public bool HasSimplifiedForm { get { return radicalData.HasSimplifiedForm; } }
|
||||
|
||||
internal CjkRadicalInfo(byte radicalIndex, CjkRadicalData radicalData)
|
||||
|
||||
@@ -7,10 +7,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Allows enumeration of the code points contained in an encapsulated string.</summary>
|
||||
/// <remarks>
|
||||
/// This enumerable will only allow enumeration of valid UTF-16 strings.
|
||||
/// For incomplete or invalid UTF-16 strings, please use <see cref="PermissiveCodePointEnumerable"/> instead.
|
||||
/// </remarks>
|
||||
public struct CodePointEnumerable : IEnumerable<int>
|
||||
{
|
||||
private readonly string text;
|
||||
|
||||
/// <summary>Initializes a new instance of the struct <see cref="CodePointEnumerable"/>.</summary>
|
||||
/// <param name="text">The string whose code points must be enumerated.</param>
|
||||
public CodePointEnumerable(string text)
|
||||
{
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
@@ -18,8 +25,10 @@ namespace System.Unicode
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/// <summary>Gets the text whose code points are being enumerated.</summary>
|
||||
public string Text { get { return text; } }
|
||||
|
||||
/// <summary>Gets an enumerator which can be used to enumerate the code points in the text.</summary>
|
||||
public CodePointEnumerator GetEnumerator()
|
||||
{
|
||||
return new CodePointEnumerator(text);
|
||||
|
||||
@@ -7,10 +7,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Allows enumeration of the code points contained in an encapsulated string, even when this one contains lone surrogates.</summary>
|
||||
/// <remarks>
|
||||
/// This enumerable will allow enumeration of UTF-16 strings containing lone surrogates.
|
||||
/// For a more conformant enumeration of code points, please use <see cref="CodePointEnumerable"/> instead.
|
||||
/// </remarks>
|
||||
public struct PermissiveCodePointEnumerable : IEnumerable<int>
|
||||
{
|
||||
private readonly string text;
|
||||
|
||||
/// <summary>Initializes a new instance of the struct <see cref="PermissiveCodePointEnumerable"/>.</summary>
|
||||
/// <param name="text">The string whose code points must be enumerated.</param>
|
||||
public PermissiveCodePointEnumerable(string text)
|
||||
{
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
@@ -18,8 +25,11 @@ namespace System.Unicode
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/// <summary>Gets the text whose code points are being enumerated.</summary>
|
||||
public string Text { get { return text; } }
|
||||
|
||||
/// <summary>Gets an enumerator which can be used to enumerate the code points in the text.</summary>
|
||||
/// <returns></returns>
|
||||
public PermissiveCodePointEnumerator GetEnumerator()
|
||||
{
|
||||
return new PermissiveCodePointEnumerator(text);
|
||||
|
||||
@@ -6,13 +6,28 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Contains extension methods applicable to the <see cref="string"/> type.</summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>Encapsulates the string in an object which can be used to enumerate code points.</summary>
|
||||
/// <remarks>
|
||||
/// The enumerable returned by this method enumerates code points in a strict manner.
|
||||
/// If the string contains lone surrogates, the enumeration will throw.
|
||||
/// </remarks>
|
||||
/// <param name="s">The string to encapsulate.</param>
|
||||
/// <returns>An enumerable object, which can be used to enumerate code points in the string.</returns>
|
||||
public static CodePointEnumerable AsCodePointEnumerable(this string s)
|
||||
{
|
||||
return new CodePointEnumerable(s);
|
||||
}
|
||||
|
||||
/// <summary>Encapsulates the string in an object which can be used to enumerate code points in a permissive way.</summary>
|
||||
/// <remarks>
|
||||
/// The enumerable returned by this method is permissive, regarding the code points represented.
|
||||
/// It allows invalid sequences, such as lone surrogates, the enumeration will handle those gracefully.
|
||||
/// </remarks>
|
||||
/// <param name="s">The string to encapsulate.</param>
|
||||
/// <returns>An enumerable object, which can be used to enumerate code points in the string.</returns>
|
||||
public static PermissiveCodePointEnumerable AsPermissiveCodePointEnumerable(this string s)
|
||||
{
|
||||
return new PermissiveCodePointEnumerable(s);
|
||||
|
||||
@@ -7,73 +7,183 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Provides information on a specific unicode code point.</summary>
|
||||
public struct UnicodeCharInfo
|
||||
{
|
||||
/// <summary>The code point.</summary>
|
||||
private readonly int codePoint;
|
||||
/// <summary>The name of the code point.</summary>
|
||||
private readonly string name;
|
||||
private readonly UnicodeCharacterData unicodeCharacterData;
|
||||
private readonly UnihanCharacterData unihanCharacterData;
|
||||
private readonly string block;
|
||||
|
||||
/// <summary>Gets the code point as an UTF-32 value.</summary>
|
||||
public int CodePoint { get { return codePoint; } }
|
||||
|
||||
/// <summary>Gets the code point name.</summary>
|
||||
/// <remarks>This is the Name Unicode property.</remarks>
|
||||
[ValueName("Name"), ValueName("na")]
|
||||
public string Name { get { return name; } }
|
||||
/// <summary>Gets the name aliases defined for the code point.</summary>
|
||||
/// <remarks>This is the Name_Alias Unicode property.</remarks>
|
||||
[ValueName("Name_Alias")]
|
||||
public UnicodeNameAliasCollection NameAliases { get { return new UnicodeNameAliasCollection(unicodeCharacterData?.NameAliases); } }
|
||||
|
||||
/// <summary>Gets the category defined for the code point.</summary>
|
||||
/// <remarks>This is the General_Category Unicode property.</remarks>
|
||||
[ValueName("General_Category"), ValueName("gc")]
|
||||
public UnicodeCategory Category { get { return unicodeCharacterData?.Category ?? UnicodeCategory.OtherNotAssigned; } }
|
||||
/// <summary>Gets the name of the block where the code point is located.</summary>
|
||||
/// <remarks>This is the Block Unicode property.</remarks>
|
||||
[ValueName("Block"), ValueName("blk")]
|
||||
public string Block { get { return block ?? UnicodeInfo.DefaultBlock; } }
|
||||
/// <summary>Gets the canonical combining class defined for the code point.</summary>
|
||||
/// <remarks>This is the Canonical_Combining_Class Unicode property.</remarks>
|
||||
[ValueName("Canonical_Combining_Class"), ValueName("ccc")]
|
||||
public CanonicalCombiningClass CanonicalCombiningClass { get { return unicodeCharacterData?.CanonicalCombiningClass ?? CanonicalCombiningClass.NotReordered; } }
|
||||
/// <summary>Gets the bidirectional class defined for the code point.</summary>
|
||||
/// <remarks>This is the Bidi_Class Unicode property.</remarks>
|
||||
[ValueName("Bidi_Class"), ValueName("bc")]
|
||||
public BidirectionalClass BidirectionalClass { get { return unicodeCharacterData?.BidirectionalClass ?? BidirectionalClass.LeftToRight; } }
|
||||
/// <summary>Gets the decomposition type defined for the code point.</summary>
|
||||
/// <remarks>This is the Decomposition_Type Unicode property.</remarks>
|
||||
[ValueName("Decomposition_Type"), ValueName("dt")]
|
||||
public CompatibilityFormattingTag DecompositionType { get { return unicodeCharacterData?.DecompositionType ?? CompatibilityFormattingTag.Canonical; } }
|
||||
/// <summary>Gets the decomposition mapping defined for the code point.</summary>
|
||||
/// <remarks>This is the Decomposition_Mapping Unicode property.</remarks>
|
||||
[ValueName("Decomposition_Mapping"), ValueName("dm")]
|
||||
public string DecompositionMapping { get { return unicodeCharacterData?.DecompositionMapping; } }
|
||||
/// <summary>Gets the numeric type defined for the code point.</summary>
|
||||
/// <remarks>
|
||||
/// This is the Numeric_Type Unicode property.
|
||||
/// When this value is defined to something other than <see cref="UnicodeNumericType.None"/>, the <see cref="NumericValue"/> indicates the numeric value of the code point.
|
||||
/// The value of this property may be influenced by Unihan data, which will set it to <see cref="UnicodeNumericType.Numeric"/>.
|
||||
/// In this case, the property <see cref="UnihanNumericType"/> will indicate the origin of the numeric value in Unihan data.
|
||||
/// </remarks>
|
||||
[ValueName("Numeric_Type"), ValueName("nt")]
|
||||
public UnicodeNumericType NumericType { get { return unihanCharacterData != null ? unihanCharacterData.NumericType != UnihanNumericType.None ? UnicodeNumericType.Numeric : UnicodeNumericType.None : unicodeCharacterData?.NumericType ?? UnicodeNumericType.None; } }
|
||||
/// <summary>Gets the Unihan numeric type defined for the code point.</summary>
|
||||
/// <remarks>The value of this property indicates which of the kPrimaryNumeric, kAccountingNumeric, or kOtherNumeric Unihan property is set, if any.</remarks>
|
||||
public UnihanNumericType UnihanNumericType { get { return unihanCharacterData != null ? unihanCharacterData.NumericType : UnihanNumericType.None; } }
|
||||
/// <summary>Gets the numeric value defined for the code point.</summary>
|
||||
/// <remarks>
|
||||
/// This is the Numeric_Value Unicode property.
|
||||
/// This value may come from Unihan data.
|
||||
/// When this property set, the <see cref="NumericType"/> and <see cref="UnihanNumericType"/> indicates the nature of the numeric value.
|
||||
/// </remarks>
|
||||
[ValueName("Numeric_Value"), ValueName("nv")]
|
||||
public UnicodeRationalNumber? NumericValue { get { return unihanCharacterData != null && unihanCharacterData.NumericType != UnihanNumericType.None ? new UnicodeRationalNumber(unihanCharacterData.NumericValue, 1) : unicodeCharacterData?.NumericValue; } }
|
||||
/// <summary>Gets a value indicating whether the character is mirrored in bidirectional text.</summary>
|
||||
/// <remarks>This is the Bidi_Mirrored Unicode property.</remarks>
|
||||
[ValueName("Bidi_Mirrored")]
|
||||
public bool BidirectionalMirrored { get { return unicodeCharacterData?.BidirectionalMirrored ?? false; } }
|
||||
/// <summary>Gets the Unicode 1 name of the code point.</summary>
|
||||
/// <remarks>This is the Unicode_1_Name Unicode property.</remarks>
|
||||
[ValueName("Unicode_1_Name"), ValueName("na1")]
|
||||
public string OldName { get { return unicodeCharacterData?.OldName; } }
|
||||
/// <summary>Gets the simple uppercase mapping defined for the code point.</summary>
|
||||
/// <remarks>This is the Simple_Uppercase_Mapping Unicode property.</remarks>
|
||||
[ValueName("Simple_Uppercase_Mapping"), ValueName("suc")]
|
||||
public string SimpleUpperCaseMapping { get { return unicodeCharacterData?.SimpleUpperCaseMapping; } }
|
||||
/// <summary>Gets the simple lowercase mapping defined for the code point.</summary>
|
||||
/// <remarks>This is the Simple_Lowercase_Mapping Unicode property.</remarks>
|
||||
[ValueName("Simple_Lowercase_Mapping"), ValueName("slc")]
|
||||
public string SimpleLowerCaseMapping { get { return unicodeCharacterData?.SimpleLowerCaseMapping; } }
|
||||
/// <summary>Gets the simple titlecase mapping defined for the code point.</summary>
|
||||
/// <remarks>This is the Simple_Titlecase_Mapping Unicode property.</remarks>
|
||||
[ValueName("Simple_Titlecase_Mapping"), ValueName("stc")]
|
||||
public string SimpleTitleCaseMapping { get { return unicodeCharacterData?.SimpleTitleCaseMapping; } }
|
||||
/// <summary>Gets a value indicating which of the boolean contributory properties are defined for the code point.</summary>
|
||||
/// <remarks>
|
||||
/// The Unicode standard indicates contributory properties as neither normative nor informational.
|
||||
/// However, contributory properties are used by Unicode to define the code properties.
|
||||
/// The corresponding core properties may be accessed from the <see cref="CoreProperties"/> member.
|
||||
/// </remarks>
|
||||
public ContributoryProperties ContributoryProperties { get { return unicodeCharacterData?.ContributoryProperties ?? 0; } }
|
||||
/// <summary>Gets a value indicating which of the boolean core properties are defined for the code point.</summary>
|
||||
/// <remarks>The core properties are computed by combining various character information together with contributory properties.</remarks>
|
||||
public CoreProperties CoreProperties { get { return unicodeCharacterData?.CoreProperties ?? 0; } }
|
||||
/// <summary>Gets a collection of cross references associated with the code point.</summary>
|
||||
/// <remarks>The cross references have been extracted from Unicode data but are not normative.</remarks>
|
||||
public UnicodeCrossReferenceCollection CrossRerefences { get { return new UnicodeCrossReferenceCollection(unicodeCharacterData?.CrossRerefences); } }
|
||||
/// <summary>Gets the radical and stroke count for the code point.</summary>
|
||||
/// <remarks>
|
||||
/// This is the Unicode_Radical_Stroke Unicode property, defined as kRSUnicode in Unihan data.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kRSUnicode"), ValueName("cjkRSUnicode"), ValueName("Unicode_Radical_Stroke"), ValueName("URS")]
|
||||
public UnicodeRadicalStrokeCountCollection UnicodeRadicalStrokeCounts { get { return new UnicodeRadicalStrokeCountCollection(unihanCharacterData?.UnicodeRadicalStrokeCounts); } }
|
||||
|
||||
/// <summary>Gets the definition of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kDefinition Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kDefinition")]
|
||||
public string Definition { get { return unihanCharacterData?.Definition; } }
|
||||
/// <summary>Gets the Mandarin reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kMandarin Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kMandarin")]
|
||||
public string MandarinReading { get { return unihanCharacterData?.MandarinReading; } }
|
||||
/// <summary>Gets the Cantonese reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kCantonese Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kCantonese")]
|
||||
public string CantoneseReading { get { return unihanCharacterData?.CantoneseReading; } }
|
||||
/// <summary>Gets the Japanese Kun reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kJapaneseKun Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kJapaneseKun")]
|
||||
public string JapaneseKunReading { get { return unihanCharacterData?.JapaneseKunReading; } }
|
||||
/// <summary>Gets the Japanese On reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kJapaneseOn Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kJapaneseOn")]
|
||||
public string JapaneseOnReading { get { return unihanCharacterData?.JapaneseOnReading; } }
|
||||
/// <summary>Gets the Korean reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kKorean Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kKorean")]
|
||||
public string KoreanReading { get { return unihanCharacterData?.KoreanReading; } }
|
||||
/// <summary>Gets the Hangul reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kHangul Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kHangul")]
|
||||
public string HangulReading { get { return unihanCharacterData?.HangulReading; } }
|
||||
/// <summary>Gets the Vietnamese reading of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kVietnamese Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kVietnamese")]
|
||||
public string VietnameseReading { get { return unihanCharacterData?.VietnameseReading; } }
|
||||
|
||||
/// <summary>Gets the simplified variant of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kSimplifiedVariant Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kSimplifiedVariant")]
|
||||
public string SimplifiedVariant { get { return unihanCharacterData?.SimplifiedVariant; } }
|
||||
/// <summary>Gets the traditional variant of the character from the Unihan data.</summary>
|
||||
/// <remarks>
|
||||
/// This is the kTraditionalVariant Unicode property.
|
||||
/// This property is only ever useful when the character is a CJK ideograph.
|
||||
/// </remarks>
|
||||
[ValueName("kTraditionalVariant")]
|
||||
public string TraditionalVariant { get { return unihanCharacterData?.TraditionalVariant; } }
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Provides access to unicode information.</summary>
|
||||
public static class UnicodeInfo
|
||||
{
|
||||
/// <summary>The block name returned when no block is assigned to a specific code point.</summary>
|
||||
public const string DefaultBlock = "No_Block";
|
||||
|
||||
private static readonly Version unicodeVersion;
|
||||
@@ -280,6 +282,7 @@ namespace System.Unicode
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the version of the Unicode standard supported by the class.</summary>
|
||||
public static Version UnicodeVersion { get { return unicodeVersion; } }
|
||||
|
||||
private static UnicodeCharacterData FindUnicodeCodePoint(int codePoint)
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DocumentationFile>bin\Debug\UnicodeInformation.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -42,8 +41,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\UnicodeInformation.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
|
||||
@@ -6,8 +6,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Represents a rational number in a format compatible with the Unicode standard.</summary>
|
||||
public struct UnicodeRationalNumber : IEquatable<UnicodeRationalNumber>
|
||||
{
|
||||
/// <summary>Parses a rational number from a string representation.</summary>
|
||||
/// <remarks>
|
||||
/// Valid text representations should match the regex pattern /-?[0-9]+(?:\/[0-9]+)/.
|
||||
/// The numerator part should fit in a <see cref="long"/>, and the denominator part should fit in a <see cref="byte"/>.
|
||||
/// </remarks>
|
||||
/// <param name="s">The string to parse.</param>
|
||||
/// <returns>The rational number parsed from the string.</returns>
|
||||
/// <exception cref="ArgumentNullException">The parameter <paramref name="s"/> is <see langword="null"/>.</exception>
|
||||
/// <exception cref="ArgumentException">The parameter <paramref name="s"/> is empty.</exception>
|
||||
public static UnicodeRationalNumber Parse(string s)
|
||||
{
|
||||
if (s == null) throw new ArgumentNullException(nameof(s));
|
||||
@@ -18,39 +28,58 @@ namespace System.Unicode
|
||||
return new UnicodeRationalNumber(long.Parse(fractionBarIndex >= 0 ? s.Substring(0, fractionBarIndex) : s), fractionBarIndex >= 0 ? byte.Parse(s.Substring(fractionBarIndex + 1)) : (byte)1);
|
||||
}
|
||||
|
||||
/// <summary>The numerator of the fraction.</summary>
|
||||
public readonly long Numerator;
|
||||
/// <summary>The denominator of the fraction.</summary>
|
||||
public readonly byte Denominator;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnicodeRationalNumber"/> structure that represents a signed integer..</summary>
|
||||
/// <param name="number">The number which should be represented as a rational number.</param>
|
||||
public UnicodeRationalNumber(long number)
|
||||
{
|
||||
this.Numerator = number;
|
||||
this.Denominator = 1;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="UnicodeRationalNumber"/> structure that represents a signed integer..</summary>
|
||||
/// <param name="numerator">The number which should be used as numerator in the rational number.</param>
|
||||
/// <param name="denominator">The number which should be used as denominator in the rational number.</param>
|
||||
public UnicodeRationalNumber(long numerator, byte denominator)
|
||||
{
|
||||
this.Numerator = numerator;
|
||||
this.Denominator = denominator;
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether the current value is the default value of the type.</summary>
|
||||
/// <remarks>The default value is an invalid fraction of 0/0.</remarks>
|
||||
public bool IsDefaultValue { get { return Numerator == 0 && Denominator == 0; } }
|
||||
|
||||
/// <summary>Creates a string representation of the current rational number.</summary>
|
||||
/// <returns>The created representation is culture invariant, and will be parsable by the <see cref="Parse(string)"/> method.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return !IsDefaultValue ? Denominator != 1 ? Numerator.ToString() + "/" + Denominator.ToString() : Numerator.ToString() : string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the specified rational number is equal to the current value.</summary>
|
||||
/// <param name="other">The other value to compare to the current one.</param>
|
||||
/// <returns><see langword="true"/> if the two values are the same; <see langword="false"/> otherwise.</returns>
|
||||
public bool Equals(UnicodeRationalNumber other)
|
||||
{
|
||||
// We don't consider 1/2 and 2/4 equal here, as, that wouldn't be the same character.
|
||||
return other.Numerator == Numerator && other.Denominator == Denominator;
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the specified object is equal to the current rational number.</summary>
|
||||
/// <param name="obj">The object to compare to the current rational number.</param>
|
||||
/// <returns><see langword="true"/> if the object represents the same rational number; <see langword="false"/> otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
/// <summary>Returns the hash code for the current rational number.</summary>
|
||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)(Numerator << 8) | (Denominator) ^ (byte)(Numerator >> 56);
|
||||
|
||||
@@ -6,13 +6,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System.Unicode
|
||||
{
|
||||
/// <summary>Declares a name for a specific value.</summary>
|
||||
/// <remarks>
|
||||
/// Since this project tries to stick to the .NET Framework naming conventions, this attribute may be used to indicate standard property names and values names where applicable.
|
||||
/// It may also be of use when aliases are available for a given property or value.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)]
|
||||
public sealed class ValueNameAttribute : Attribute
|
||||
{
|
||||
private readonly string name;
|
||||
|
||||
/// <summary>The name given to the property or value.</summary>
|
||||
public string Name { get { return name; } }
|
||||
|
||||
/// <summary>Initializes an instance of the class <see cref="ValueNameAttribute"/>.</summary>
|
||||
/// <param name="name">The name given to the property or value on which this attribute is to be applied.</param>
|
||||
public ValueNameAttribute(string name)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
Reference in New Issue
Block a user