diff --git a/UnicodeInformation/BidirectionalClass.cs b/UnicodeInformation/BidirectionalClass.cs index 26105ac..8e8f716 100644 --- a/UnicodeInformation/BidirectionalClass.cs +++ b/UnicodeInformation/BidirectionalClass.cs @@ -7,53 +7,100 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Represents possible values for the Bidi_Class unicode property. public enum BidirectionalClass : byte { - [ValueName("L"), ValueName("Left_To_Right"), Display(Name = "Left_To_Right", Description = "any strong left-to-right character")] + /// Represents the value Left_To_Right. + /// Any strong left-to-right character. + [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")] + /// Represents the value Right_To_Left. + /// Any strong right-to-left (non-Arabic-type) character. + [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")] + /// Represents the value Arabic_Letter. + /// Any strong right-to-left (Arabic-type) character. + [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")] + /// Represents the value European_Number. + /// Any ASCII digit or Eastern Arabic-Indic digit. + [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")] + /// Represents the value European_Separator. + /// Plus and minus signs. + [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")] + /// Represents the value European_Terminator. + /// A terminator in a numeric format context, includes currency signs. + [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")] + /// Represents the value Arabic_Number. + /// Any Arabic-Indic digit. + [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")] + /// Represents the value Common_Separator. + /// Commas, colons, and slashes. + [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")] + /// Represents the value Nonspacing_Mark. + /// Any nonspacing mark. + [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")] + /// Represents the value Boundary_Neutral. + /// Most format characters, control codes, or noncharacters. + [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")] + /// Represents the value Paragraph_Separator. + /// Various newline characters. + [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")] + /// Represents the value Segment_Separator. + /// Various segment-related control codes. + [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")] + /// Represents the value White_Space. + /// Spaces. + [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")] + /// Represents the value Other_Neutral. + /// Most other symbols and punctuation marks. + [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")] + /// Represents the value Left_To_Right_Embedding. + /// U+202A: the LR embedding control. + [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")] + /// Represents the value Left_To_Right_Override. + /// U+202D: the LR override control. + [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")] + /// Represents the value Right_To_Left_Embedding. + /// U+202B: the RL embedding control. + [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")] + /// Represents the value Right_To_Left_Override. + /// U+202E: the RL override control. + [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")] + /// Represents the value Pop_Directional_Format. + /// U+202C: terminates an embedding or override control. + [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")] + /// Represents the value Left_To_Right_Isolate. + /// U+2066: the LR isolate control. + [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")] + /// Represents the value Right_To_Left_Isolate. + /// U+2067: the RL isolate control. + [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")] + /// Represents the value First_Strong_Isolate. + /// U+2068: the first strong isolate control. + [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")] + /// Represents the value Pop_Directional_Isolate. + /// U+2069: terminates an isolate control. + [ValueName("PDI"), ValueName("Pop_Directional_Isolate"), Display(Name = "Pop_Directional_Isolate", Description = "U+2069: terminates an isolate control.")] PopDirectionalIsolate, } } diff --git a/UnicodeInformation/CjkRadicalInfo.cs b/UnicodeInformation/CjkRadicalInfo.cs index 892d7ea..f64a3ae 100644 --- a/UnicodeInformation/CjkRadicalInfo.cs +++ b/UnicodeInformation/CjkRadicalInfo.cs @@ -6,18 +6,35 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Provides information on a specific CJK radical. public struct CjkRadicalInfo { private readonly byte radicalIndex; private readonly CjkRadicalData radicalData; + /// The index of the radical in the Kangxi dictionary. + /// There are 214 radicals, numbered from 1 to 214. public byte RadicalIndex { get { return radicalIndex; } } + /// Gets a code point representing the CJK radical in its traditional form. public char TraditionalRadicalCodePoint { get { return radicalData.TraditionalRadicalCodePoint; } } + /// Gets the code point of a traditional character composed only of the CJK radical. + /// + /// Usually, the glyph of this code point will be the same as the one used for . + /// However, the code point returned will have a meaning associated, contrary to the one returned by , which only represents the radical. + /// public char TraditionalCharacterCodePoint { get { return radicalData.TraditionalCharacterCodePoint; } } + /// Gets a code point representing the CJK radical in its simplified form, which may be the same as the traditional form. + /// Most of the time, the value returned will be the same as . public char SimplifiedRadicalCodePoint { get { return radicalData.SimplifiedRadicalCodePoint; } } + /// Gets the code point of a simplified character composed only of the CJK radical. + /// + /// Usually, the glyph of this code point will be the same as the one used for . + /// However, the code point returned will have a meaning associated, contrary to the one returned by , which only represents the radical. + /// public char SimplifiedCharacterCodePoint { get { return radicalData.SimplifiedCharacterCodePoint; } } + /// Gets a value indicating whether a simplified form exists for the given radical. public bool HasSimplifiedForm { get { return radicalData.HasSimplifiedForm; } } internal CjkRadicalInfo(byte radicalIndex, CjkRadicalData radicalData) diff --git a/UnicodeInformation/CodePointEnumerable.cs b/UnicodeInformation/CodePointEnumerable.cs index 3c88f1d..34a3aaa 100644 --- a/UnicodeInformation/CodePointEnumerable.cs +++ b/UnicodeInformation/CodePointEnumerable.cs @@ -7,10 +7,17 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Allows enumeration of the code points contained in an encapsulated string. + /// + /// This enumerable will only allow enumeration of valid UTF-16 strings. + /// For incomplete or invalid UTF-16 strings, please use instead. + /// public struct CodePointEnumerable : IEnumerable { private readonly string text; + /// Initializes a new instance of the struct . + /// The string whose code points must be enumerated. public CodePointEnumerable(string text) { if (text == null) throw new ArgumentNullException(nameof(text)); @@ -18,8 +25,10 @@ namespace System.Unicode this.text = text; } + /// Gets the text whose code points are being enumerated. public string Text { get { return text; } } + /// Gets an enumerator which can be used to enumerate the code points in the text. public CodePointEnumerator GetEnumerator() { return new CodePointEnumerator(text); diff --git a/UnicodeInformation/PermissiveCodePointEnumerable.cs b/UnicodeInformation/PermissiveCodePointEnumerable.cs index a5f74c2..c068ca1 100644 --- a/UnicodeInformation/PermissiveCodePointEnumerable.cs +++ b/UnicodeInformation/PermissiveCodePointEnumerable.cs @@ -7,10 +7,17 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Allows enumeration of the code points contained in an encapsulated string, even when this one contains lone surrogates. + /// + /// This enumerable will allow enumeration of UTF-16 strings containing lone surrogates. + /// For a more conformant enumeration of code points, please use instead. + /// public struct PermissiveCodePointEnumerable : IEnumerable { private readonly string text; + /// Initializes a new instance of the struct . + /// The string whose code points must be enumerated. public PermissiveCodePointEnumerable(string text) { if (text == null) throw new ArgumentNullException(nameof(text)); @@ -18,8 +25,11 @@ namespace System.Unicode this.text = text; } + /// Gets the text whose code points are being enumerated. public string Text { get { return text; } } + /// Gets an enumerator which can be used to enumerate the code points in the text. + /// public PermissiveCodePointEnumerator GetEnumerator() { return new PermissiveCodePointEnumerator(text); diff --git a/UnicodeInformation/StringExtensions.cs b/UnicodeInformation/StringExtensions.cs index 99c008f..172529a 100644 --- a/UnicodeInformation/StringExtensions.cs +++ b/UnicodeInformation/StringExtensions.cs @@ -6,13 +6,28 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Contains extension methods applicable to the type. public static class StringExtensions { + /// Encapsulates the string in an object which can be used to enumerate code points. + /// + /// The enumerable returned by this method enumerates code points in a strict manner. + /// If the string contains lone surrogates, the enumeration will throw. + /// + /// The string to encapsulate. + /// An enumerable object, which can be used to enumerate code points in the string. public static CodePointEnumerable AsCodePointEnumerable(this string s) { return new CodePointEnumerable(s); } + /// Encapsulates the string in an object which can be used to enumerate code points in a permissive way. + /// + /// 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. + /// + /// The string to encapsulate. + /// An enumerable object, which can be used to enumerate code points in the string. public static PermissiveCodePointEnumerable AsPermissiveCodePointEnumerable(this string s) { return new PermissiveCodePointEnumerable(s); diff --git a/UnicodeInformation/UnicodeCharInfo.cs b/UnicodeInformation/UnicodeCharInfo.cs index 7bd84e8..5ed6800 100644 --- a/UnicodeInformation/UnicodeCharInfo.cs +++ b/UnicodeInformation/UnicodeCharInfo.cs @@ -7,73 +7,183 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Provides information on a specific unicode code point. public struct UnicodeCharInfo { + /// The code point. private readonly int codePoint; + /// The name of the code point. private readonly string name; private readonly UnicodeCharacterData unicodeCharacterData; private readonly UnihanCharacterData unihanCharacterData; private readonly string block; + /// Gets the code point as an UTF-32 value. public int CodePoint { get { return codePoint; } } + /// Gets the code point name. + /// This is the Name Unicode property. [ValueName("Name"), ValueName("na")] public string Name { get { return name; } } + /// Gets the name aliases defined for the code point. + /// This is the Name_Alias Unicode property. [ValueName("Name_Alias")] public UnicodeNameAliasCollection NameAliases { get { return new UnicodeNameAliasCollection(unicodeCharacterData?.NameAliases); } } + /// Gets the category defined for the code point. + /// This is the General_Category Unicode property. [ValueName("General_Category"), ValueName("gc")] public UnicodeCategory Category { get { return unicodeCharacterData?.Category ?? UnicodeCategory.OtherNotAssigned; } } + /// Gets the name of the block where the code point is located. + /// This is the Block Unicode property. [ValueName("Block"), ValueName("blk")] public string Block { get { return block ?? UnicodeInfo.DefaultBlock; } } + /// Gets the canonical combining class defined for the code point. + /// This is the Canonical_Combining_Class Unicode property. [ValueName("Canonical_Combining_Class"), ValueName("ccc")] public CanonicalCombiningClass CanonicalCombiningClass { get { return unicodeCharacterData?.CanonicalCombiningClass ?? CanonicalCombiningClass.NotReordered; } } + /// Gets the bidirectional class defined for the code point. + /// This is the Bidi_Class Unicode property. [ValueName("Bidi_Class"), ValueName("bc")] public BidirectionalClass BidirectionalClass { get { return unicodeCharacterData?.BidirectionalClass ?? BidirectionalClass.LeftToRight; } } + /// Gets the decomposition type defined for the code point. + /// This is the Decomposition_Type Unicode property. [ValueName("Decomposition_Type"), ValueName("dt")] public CompatibilityFormattingTag DecompositionType { get { return unicodeCharacterData?.DecompositionType ?? CompatibilityFormattingTag.Canonical; } } + /// Gets the decomposition mapping defined for the code point. + /// This is the Decomposition_Mapping Unicode property. [ValueName("Decomposition_Mapping"), ValueName("dm")] public string DecompositionMapping { get { return unicodeCharacterData?.DecompositionMapping; } } + /// Gets the numeric type defined for the code point. + /// + /// This is the Numeric_Type Unicode property. + /// When this value is defined to something other than , the indicates the numeric value of the code point. + /// The value of this property may be influenced by Unihan data, which will set it to . + /// In this case, the property will indicate the origin of the numeric value in Unihan data. + /// [ValueName("Numeric_Type"), ValueName("nt")] public UnicodeNumericType NumericType { get { return unihanCharacterData != null ? unihanCharacterData.NumericType != UnihanNumericType.None ? UnicodeNumericType.Numeric : UnicodeNumericType.None : unicodeCharacterData?.NumericType ?? UnicodeNumericType.None; } } + /// Gets the Unihan numeric type defined for the code point. + /// The value of this property indicates which of the kPrimaryNumeric, kAccountingNumeric, or kOtherNumeric Unihan property is set, if any. public UnihanNumericType UnihanNumericType { get { return unihanCharacterData != null ? unihanCharacterData.NumericType : UnihanNumericType.None; } } + /// Gets the numeric value defined for the code point. + /// + /// This is the Numeric_Value Unicode property. + /// This value may come from Unihan data. + /// When this property set, the and indicates the nature of the numeric value. + /// [ValueName("Numeric_Value"), ValueName("nv")] public UnicodeRationalNumber? NumericValue { get { return unihanCharacterData != null && unihanCharacterData.NumericType != UnihanNumericType.None ? new UnicodeRationalNumber(unihanCharacterData.NumericValue, 1) : unicodeCharacterData?.NumericValue; } } + /// Gets a value indicating whether the character is mirrored in bidirectional text. + /// This is the Bidi_Mirrored Unicode property. [ValueName("Bidi_Mirrored")] public bool BidirectionalMirrored { get { return unicodeCharacterData?.BidirectionalMirrored ?? false; } } + /// Gets the Unicode 1 name of the code point. + /// This is the Unicode_1_Name Unicode property. [ValueName("Unicode_1_Name"), ValueName("na1")] public string OldName { get { return unicodeCharacterData?.OldName; } } + /// Gets the simple uppercase mapping defined for the code point. + /// This is the Simple_Uppercase_Mapping Unicode property. [ValueName("Simple_Uppercase_Mapping"), ValueName("suc")] public string SimpleUpperCaseMapping { get { return unicodeCharacterData?.SimpleUpperCaseMapping; } } + /// Gets the simple lowercase mapping defined for the code point. + /// This is the Simple_Lowercase_Mapping Unicode property. [ValueName("Simple_Lowercase_Mapping"), ValueName("slc")] public string SimpleLowerCaseMapping { get { return unicodeCharacterData?.SimpleLowerCaseMapping; } } + /// Gets the simple titlecase mapping defined for the code point. + /// This is the Simple_Titlecase_Mapping Unicode property. [ValueName("Simple_Titlecase_Mapping"), ValueName("stc")] public string SimpleTitleCaseMapping { get { return unicodeCharacterData?.SimpleTitleCaseMapping; } } + /// Gets a value indicating which of the boolean contributory properties are defined for the code point. + /// + /// 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 member. + /// public ContributoryProperties ContributoryProperties { get { return unicodeCharacterData?.ContributoryProperties ?? 0; } } + /// Gets a value indicating which of the boolean core properties are defined for the code point. + /// The core properties are computed by combining various character information together with contributory properties. public CoreProperties CoreProperties { get { return unicodeCharacterData?.CoreProperties ?? 0; } } + /// Gets a collection of cross references associated with the code point. + /// The cross references have been extracted from Unicode data but are not normative. public UnicodeCrossReferenceCollection CrossRerefences { get { return new UnicodeCrossReferenceCollection(unicodeCharacterData?.CrossRerefences); } } + /// Gets the radical and stroke count for the code point. + /// + /// 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. + /// [ValueName("kRSUnicode"), ValueName("cjkRSUnicode"), ValueName("Unicode_Radical_Stroke"), ValueName("URS")] public UnicodeRadicalStrokeCountCollection UnicodeRadicalStrokeCounts { get { return new UnicodeRadicalStrokeCountCollection(unihanCharacterData?.UnicodeRadicalStrokeCounts); } } + /// Gets the definition of the character from the Unihan data. + /// + /// This is the kDefinition Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kDefinition")] public string Definition { get { return unihanCharacterData?.Definition; } } + /// Gets the Mandarin reading of the character from the Unihan data. + /// + /// This is the kMandarin Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kMandarin")] public string MandarinReading { get { return unihanCharacterData?.MandarinReading; } } + /// Gets the Cantonese reading of the character from the Unihan data. + /// + /// This is the kCantonese Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kCantonese")] public string CantoneseReading { get { return unihanCharacterData?.CantoneseReading; } } + /// Gets the Japanese Kun reading of the character from the Unihan data. + /// + /// This is the kJapaneseKun Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kJapaneseKun")] public string JapaneseKunReading { get { return unihanCharacterData?.JapaneseKunReading; } } + /// Gets the Japanese On reading of the character from the Unihan data. + /// + /// This is the kJapaneseOn Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kJapaneseOn")] public string JapaneseOnReading { get { return unihanCharacterData?.JapaneseOnReading; } } + /// Gets the Korean reading of the character from the Unihan data. + /// + /// This is the kKorean Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kKorean")] public string KoreanReading { get { return unihanCharacterData?.KoreanReading; } } + /// Gets the Hangul reading of the character from the Unihan data. + /// + /// This is the kHangul Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kHangul")] public string HangulReading { get { return unihanCharacterData?.HangulReading; } } + /// Gets the Vietnamese reading of the character from the Unihan data. + /// + /// This is the kVietnamese Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kVietnamese")] public string VietnameseReading { get { return unihanCharacterData?.VietnameseReading; } } + /// Gets the simplified variant of the character from the Unihan data. + /// + /// This is the kSimplifiedVariant Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kSimplifiedVariant")] public string SimplifiedVariant { get { return unihanCharacterData?.SimplifiedVariant; } } + /// Gets the traditional variant of the character from the Unihan data. + /// + /// This is the kTraditionalVariant Unicode property. + /// This property is only ever useful when the character is a CJK ideograph. + /// [ValueName("kTraditionalVariant")] public string TraditionalVariant { get { return unihanCharacterData?.TraditionalVariant; } } diff --git a/UnicodeInformation/UnicodeInfo.cs b/UnicodeInformation/UnicodeInfo.cs index a319e9a..acadd3d 100644 --- a/UnicodeInformation/UnicodeInfo.cs +++ b/UnicodeInformation/UnicodeInfo.cs @@ -10,8 +10,10 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Provides access to unicode information. public static class UnicodeInfo { + /// The block name returned when no block is assigned to a specific code point. public const string DefaultBlock = "No_Block"; private static readonly Version unicodeVersion; @@ -280,6 +282,7 @@ namespace System.Unicode } } + /// Gets the version of the Unicode standard supported by the class. public static Version UnicodeVersion { get { return unicodeVersion; } } private static UnicodeCharacterData FindUnicodeCodePoint(int codePoint) diff --git a/UnicodeInformation/UnicodeInformation.csproj b/UnicodeInformation/UnicodeInformation.csproj index c767af8..21ecbfb 100644 --- a/UnicodeInformation/UnicodeInformation.csproj +++ b/UnicodeInformation/UnicodeInformation.csproj @@ -32,8 +32,7 @@ prompt 4 false - - + bin\Debug\UnicodeInformation.xml pdbonly @@ -42,8 +41,7 @@ TRACE prompt 4 - - + bin\Release\UnicodeInformation.xml true diff --git a/UnicodeInformation/UnicodeRationalNumber.cs b/UnicodeInformation/UnicodeRationalNumber.cs index 0f831eb..fa92172 100644 --- a/UnicodeInformation/UnicodeRationalNumber.cs +++ b/UnicodeInformation/UnicodeRationalNumber.cs @@ -6,8 +6,18 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Represents a rational number in a format compatible with the Unicode standard. public struct UnicodeRationalNumber : IEquatable { + /// Parses a rational number from a string representation. + /// + /// Valid text representations should match the regex pattern /-?[0-9]+(?:\/[0-9]+)/. + /// The numerator part should fit in a , and the denominator part should fit in a . + /// + /// The string to parse. + /// The rational number parsed from the string. + /// The parameter is . + /// The parameter is empty. 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); } + /// The numerator of the fraction. public readonly long Numerator; + /// The denominator of the fraction. public readonly byte Denominator; + /// Initializes a new instance of the structure that represents a signed integer.. + /// The number which should be represented as a rational number. public UnicodeRationalNumber(long number) { this.Numerator = number; this.Denominator = 1; } + /// Initializes a new instance of the structure that represents a signed integer.. + /// The number which should be used as numerator in the rational number. + /// The number which should be used as denominator in the rational number. public UnicodeRationalNumber(long numerator, byte denominator) { this.Numerator = numerator; this.Denominator = denominator; } + /// Gets a value indicating whether the current value is the default value of the type. + /// The default value is an invalid fraction of 0/0. public bool IsDefaultValue { get { return Numerator == 0 && Denominator == 0; } } + /// Creates a string representation of the current rational number. + /// The created representation is culture invariant, and will be parsable by the method. public override string ToString() { return !IsDefaultValue ? Denominator != 1 ? Numerator.ToString() + "/" + Denominator.ToString() : Numerator.ToString() : string.Empty; } + /// Determines whether the specified rational number is equal to the current value. + /// The other value to compare to the current one. + /// if the two values are the same; otherwise. 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; } + /// Determines whether the specified object is equal to the current rational number. + /// The object to compare to the current rational number. + /// if the object represents the same rational number; otherwise. public override bool Equals(object obj) { return base.Equals(obj); } + /// Returns the hash code for the current rational number. + /// A 32-bit signed integer hash code. public override int GetHashCode() { return (int)(Numerator << 8) | (Denominator) ^ (byte)(Numerator >> 56); diff --git a/UnicodeInformation/ValueNameAttribute.cs b/UnicodeInformation/ValueNameAttribute.cs index baec02a..6de05c9 100644 --- a/UnicodeInformation/ValueNameAttribute.cs +++ b/UnicodeInformation/ValueNameAttribute.cs @@ -6,13 +6,21 @@ using System.Threading.Tasks; namespace System.Unicode { + /// Declares a name for a specific value. + /// + /// 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. + /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] public sealed class ValueNameAttribute : Attribute { private readonly string name; + /// The name given to the property or value. public string Name { get { return name; } } + /// Initializes an instance of the class . + /// The name given to the property or value on which this attribute is to be applied. public ValueNameAttribute(string name) { this.name = name;