Struct CodePoint
Represents a Unicode value ([ U+0000..U+10FFFF ], inclusive).
Inherited Members
Namespace: SixLabors.Fonts.Unicode
Assembly: SixLabors.Fonts.dll
Syntax
public readonly struct CodePoint : IComparable, IComparable<CodePoint>, IEquatable<CodePoint>
Remarks
This type's constructors and conversion operators validate the input, so consumers can call the APIs assuming that the underlying CodePoint instance is well-formed.
Constructors
| Edit this page View SourceCodePoint(char)
Initializes a new instance of the CodePoint struct.
Declaration
public CodePoint(char value)
Parameters
Type | Name | Description |
---|---|---|
char | value | The char representing the UTF-16 code unit |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | If |
CodePoint(char, char)
Initializes a new instance of the CodePoint struct.
Declaration
public CodePoint(char highSurrogate, char lowSurrogate)
Parameters
Type | Name | Description |
---|---|---|
char | highSurrogate | A char representing a UTF-16 high surrogate code unit. |
char | lowSurrogate | A char representing a UTF-16 low surrogate code unit. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | If |
CodePoint(int)
Initializes a new instance of the CodePoint struct.
Declaration
public CodePoint(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to create the codepoint. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | If |
CodePoint(uint)
Initializes a new instance of the CodePoint struct.
Declaration
public CodePoint(uint value)
Parameters
Type | Name | Description |
---|---|---|
uint | value | The value to create the codepoint. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | If |
Properties
| Edit this page View SourceIsAscii
Gets a value indicating whether this value is ASCII ([ U+0000..U+007F ]) and therefore representable by a single UTF-8 code unit.
Declaration
public bool IsAscii { get; }
Property Value
Type | Description |
---|---|
bool |
IsBmp
Gets a value indicating whether this value is within the BMP ([ U+0000..U+FFFF ]) and therefore representable by a single UTF-16 code unit.
Declaration
public bool IsBmp { get; }
Property Value
Type | Description |
---|---|
bool |
Plane
Gets the Unicode plane (0 to 16, inclusive) which contains this scalar.
Declaration
public int Plane { get; }
Property Value
Type | Description |
---|---|
int |
ReplacementChar
Gets a CodePoint instance that represents the Unicode replacement character U+FFFD.
Declaration
public static CodePoint ReplacementChar { get; }
Property Value
Type | Description |
---|---|
CodePoint |
Utf16SequenceLength
Gets the length in code units (char) of the UTF-16 sequence required to represent this scalar value.
Declaration
public int Utf16SequenceLength { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
The return value will be 1 or 2.
Utf8SequenceLength
Gets the length in code units of the UTF-8 sequence required to represent this scalar value.
Declaration
public int Utf8SequenceLength { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
The return value will be 1 through 4, inclusive.
Value
Gets the Unicode value as an integer.
Declaration
public int Value { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCompareTo(CodePoint)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(CodePoint other)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | other | An object to compare with this instance. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
int | A value that indicates the relative order of the objects being compared. The return value has these meanings:
|
Equals(CodePoint)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(CodePoint other)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
| Edit this page View SourceGetBidiClass(CodePoint)
Gets the BidiClass for the given codepoint.
Declaration
public static BidiClass GetBidiClass(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
BidiClass | The BidiClass. |
GetCodePointCount(ReadOnlySpan<char>)
Returns the number of codepoints in a given string buffer.
Declaration
public static int GetCodePointCount(ReadOnlySpan<char> source)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | source | The source buffer to parse. |
Returns
Type | Description |
---|---|
int | The int count. |
GetGeneralCategory(CodePoint)
Gets the UnicodeCategory for the given codepoint.
Declaration
public static UnicodeCategory GetGeneralCategory(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
UnicodeCategory | The UnicodeCategory. |
GetGraphemeClusterClass(CodePoint)
Gets the GraphemeClusterClass for the given codepoint.
Declaration
public static GraphemeClusterClass GetGraphemeClusterClass(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
GraphemeClusterClass | The GraphemeClusterClass. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
| Edit this page View SourceGetLineBreakClass(CodePoint)
Gets the LineBreakClass for the given codepoint.
Declaration
public static LineBreakClass GetLineBreakClass(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
LineBreakClass | The LineBreakClass. |
GetVerticalOrientationType(CodePoint)
Gets the VerticalOrientationType for the given codepoint.
Declaration
public static VerticalOrientationType GetVerticalOrientationType(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
VerticalOrientationType |
IsControl(CodePoint)
Gets a value indicating whether the given codepoint is a control character.
Declaration
public static bool IsControl(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsDigit(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a decimal digit.
Declaration
public static bool IsDigit(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsLetter(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a letter.
Declaration
public static bool IsLetter(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsLetterOrDigit(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a letter or decimal digit.
Declaration
public static bool IsLetterOrDigit(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsLower(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a lowercase letter.
Declaration
public static bool IsLower(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsMark(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a mark.
Declaration
public static bool IsMark(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsNewLine(CodePoint)
Gets a value indicating whether the given codepoint is a new line indicator.
Declaration
public static bool IsNewLine(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsNonBreakingSpace(CodePoint)
Gets a value indicating whether the given codepoint is a non-breaking space.
Declaration
public static bool IsNonBreakingSpace(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsNumber(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a number.
Declaration
public static bool IsNumber(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsPunctuation(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as punctuation.
Declaration
public static bool IsPunctuation(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsSeparator(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a separator.
Declaration
public static bool IsSeparator(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsSymbol(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as a symbol.
Declaration
public static bool IsSymbol(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsTabulation(CodePoint)
Gets a value indicating whether the given codepoint is a tabulation indicator.
Declaration
public static bool IsTabulation(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsUpper(CodePoint)
Returns a value that indicates whether the specified codepoint is categorized as an uppercase letter.
Declaration
public static bool IsUpper(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool |
IsValid(int)
Returns true if value
is a valid Unicode code
point, i.e., is in [ U+0000..U+10FFFF ], inclusive.
Declaration
public static bool IsValid(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsValid(uint)
Returns true if value
is a valid Unicode code
point, i.e., is in [ U+0000..U+10FFFF ], inclusive.
Declaration
public static bool IsValid(uint value)
Parameters
Type | Name | Description |
---|---|---|
uint | value | The value to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsVariationSelector(CodePoint)
Gets a value indicating whether the given codepoint is a variation selector. https://en.wikipedia.org/wiki/Variation_Selectors_%28Unicode_block%29
Declaration
public static bool IsVariationSelector(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsWhiteSpace(CodePoint)
Gets a value indicating whether the given codepoint is white space.
Declaration
public static bool IsWhiteSpace(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsZeroWidthJoiner(CodePoint)
Gets a value indicating whether the given codepoint is a zero-width-joiner.
Declaration
public static bool IsZeroWidthJoiner(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
IsZeroWidthNonJoiner(CodePoint)
Gets a value indicating whether the given codepoint is a zero-width-non-joiner.
Declaration
public static bool IsZeroWidthNonJoiner(CodePoint codePoint)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The codepoint to evaluate. |
Returns
Type | Description |
---|---|
bool | true if |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The fully qualified type name. |
Overrides
| Edit this page View SourceTryGetBidiMirror(CodePoint, out CodePoint)
Gets the codepoint representing the bidi mirror for this instance. http://www.unicode.org/reports/tr44/#Bidi_Mirrored
Declaration
public static bool TryGetBidiMirror(CodePoint codePoint, out CodePoint mirror)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The code point to be mapped. |
CodePoint | mirror | When this method returns, contains the codepoint representing the bidi mirror for this instance;
otherwise, the default value for the type of the |
Returns
Type | Description |
---|---|
bool |
TryGetVerticalMirror(CodePoint, out CodePoint)
Gets the codepoint representing the vertical mirror for this instance. https://www.unicode.org/reports/tr50/#vertical_alternates
Declaration
public static bool TryGetVerticalMirror(CodePoint codePoint, out CodePoint mirror)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | codePoint | The code point to be mapped. |
CodePoint | mirror | When this method returns, contains the codepoint representing the vertical mirror for this instance;
otherwise, the default value for the type of the |
Returns
Type | Description |
---|---|
bool |
Operators
| Edit this page View Sourceoperator ==(CodePoint, CodePoint)
Declaration
public static bool operator ==(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |
explicit operator CodePoint(char)
Declaration
public static explicit operator CodePoint(char ch)
Parameters
Type | Name | Description |
---|---|---|
char | ch |
Returns
Type | Description |
---|---|
CodePoint |
explicit operator CodePoint(int)
Declaration
public static explicit operator CodePoint(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value |
Returns
Type | Description |
---|---|
CodePoint |
explicit operator CodePoint(uint)
Declaration
public static explicit operator CodePoint(uint value)
Parameters
Type | Name | Description |
---|---|---|
uint | value |
Returns
Type | Description |
---|---|
CodePoint |
operator >(CodePoint, CodePoint)
Declaration
public static bool operator >(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |
operator >=(CodePoint, CodePoint)
Declaration
public static bool operator >=(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |
operator !=(CodePoint, CodePoint)
Declaration
public static bool operator !=(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |
operator <(CodePoint, CodePoint)
Declaration
public static bool operator <(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |
operator <=(CodePoint, CodePoint)
Declaration
public static bool operator <=(CodePoint left, CodePoint right)
Parameters
Type | Name | Description |
---|---|---|
CodePoint | left | |
CodePoint | right |
Returns
Type | Description |
---|---|
bool |