Table of Contents

Struct CodePoint

Namespace
SixLabors.Fonts.Unicode
Assembly
SixLabors.Fonts.dll

Represents a Unicode value ([ U+0000..U+10FFFF ], inclusive).

public readonly struct CodePoint : IComparable, IComparable<CodePoint>, IEquatable<CodePoint>
Implements
Inherited Members

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

CodePoint(char)

Initializes a new instance of the CodePoint struct.

public CodePoint(char value)

Parameters

value char

The char representing the UTF-16 code unit

Exceptions

ArgumentOutOfRangeException

If value represents a UTF-16 surrogate code point U+D800..U+DFFF, inclusive.

CodePoint(char, char)

Initializes a new instance of the CodePoint struct.

public CodePoint(char highSurrogate, char lowSurrogate)

Parameters

highSurrogate char

A char representing a UTF-16 high surrogate code unit.

lowSurrogate char

A char representing a UTF-16 low surrogate code unit.

Exceptions

ArgumentOutOfRangeException

If highSurrogate does not represent a UTF-16 high surrogate code unit or lowSurrogate does not represent a UTF-16 low surrogate code unit.

CodePoint(int)

Initializes a new instance of the CodePoint struct.

public CodePoint(int value)

Parameters

value int

The value to create the codepoint.

Exceptions

ArgumentOutOfRangeException

If value does not represent a value Unicode scalar value.

CodePoint(uint)

Initializes a new instance of the CodePoint struct.

public CodePoint(uint value)

Parameters

value uint

The value to create the codepoint.

Exceptions

ArgumentOutOfRangeException

If value does not represent a value Unicode scalar value.

Properties

IsAscii

Gets a value indicating whether this value is ASCII ([ U+0000..U+007F ]) and therefore representable by a single UTF-8 code unit.

public bool IsAscii { get; }

Property Value

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.

public bool IsBmp { get; }

Property Value

bool

ObjectReplacementChar

Gets a CodePoint instance that represents the Unicode object replacement character U+FFFC.

public static CodePoint ObjectReplacementChar { get; }

Property Value

CodePoint

Plane

Gets the Unicode plane (0 to 16, inclusive) which contains this scalar.

public int Plane { get; }

Property Value

int

ReplacementChar

Gets a CodePoint instance that represents the Unicode replacement character U+FFFD.

public static CodePoint ReplacementChar { get; }

Property Value

CodePoint

Utf16SequenceLength

Gets the length in code units (char) of the UTF-16 sequence required to represent this scalar value.

public int Utf16SequenceLength { get; }

Property Value

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.

public int Utf8SequenceLength { get; }

Property Value

int

Remarks

The return value will be 1 through 4, inclusive.

Value

Gets the Unicode value as an integer.

public int Value { get; }

Property Value

int

Methods

CompareTo(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.

public int CompareTo(CodePoint other)

Parameters

other CodePoint

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

Equals(CodePoint)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CodePoint other)

Parameters

other CodePoint

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetArabicJoiningClass(in CodePoint)

Gets the ArabicJoiningClass for the given codepoint.

public static ArabicJoiningClass GetArabicJoiningClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

ArabicJoiningClass

The ArabicJoiningClass.

GetBidiClass(in CodePoint)

Gets the BidiClass for the given codepoint.

public static BidiClass GetBidiClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

BidiClass

The BidiClass.

GetCodePointCount(ReadOnlySpan<char>)

Returns the number of codepoints in a given string buffer.

public static int GetCodePointCount(ReadOnlySpan<char> source)

Parameters

source ReadOnlySpan<char>

The source buffer to parse.

Returns

int

The int count.

GetEastAsianWidthClass(in CodePoint)

Gets the EastAsianWidthClass for the given codepoint.

public static EastAsianWidthClass GetEastAsianWidthClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

EastAsianWidthClass

The EastAsianWidthClass.

Remarks

This returns the Unicode East_Asian_Width property value from UAX #11. It does not resolve context-sensitive display-cell width; for example, Ambiguous may resolve as narrow or wide depending on language, script, source encoding, font, or explicit markup.

GetEmojiProperties(in CodePoint)

Gets the EmojiProperties for the given codepoint.

public static EmojiProperties GetEmojiProperties(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

EmojiProperties

The EmojiProperties.

GetGeneralCategory(in CodePoint)

Gets the UnicodeCategory for the given codepoint.

public static UnicodeCategory GetGeneralCategory(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

UnicodeCategory

The UnicodeCategory.

GetGraphemeClusterClass(in CodePoint)

Gets the GraphemeClusterClass for the given codepoint.

public static GraphemeClusterClass GetGraphemeClusterClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

GraphemeClusterClass

The GraphemeClusterClass.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetIndicConjunctBreakClass(in CodePoint)

Gets the IndicConjunctBreakClass for the given codepoint.

public static IndicConjunctBreakClass GetIndicConjunctBreakClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

IndicConjunctBreakClass

The IndicConjunctBreakClass.

GetIndicPositionalCategory(in CodePoint)

Gets the IndicPositionalCategory for the given codepoint.

public static IndicPositionalCategory GetIndicPositionalCategory(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

IndicPositionalCategory

The IndicPositionalCategory.

GetIndicSyllabicCategory(in CodePoint)

Gets the IndicSyllabicCategory for the given codepoint.

public static IndicSyllabicCategory GetIndicSyllabicCategory(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

IndicSyllabicCategory

The IndicSyllabicCategory.

GetLineBreakClass(in CodePoint)

Gets the LineBreakClass for the given codepoint.

public static LineBreakClass GetLineBreakClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

LineBreakClass

The LineBreakClass.

GetScriptClass(in CodePoint)

Gets the ScriptClass for the given codepoint.

public static ScriptClass GetScriptClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

ScriptClass

The ScriptClass.

GetVerticalOrientationType(in CodePoint)

Gets the VerticalOrientationType for the given codepoint.

public static VerticalOrientationType GetVerticalOrientationType(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

VerticalOrientationType

The VerticalOrientationType.

GetWordBreakClass(in CodePoint)

Gets the WordBreakClass for the given codepoint.

public static WordBreakClass GetWordBreakClass(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint.

Returns

WordBreakClass

The WordBreakClass.

IsControl(in CodePoint)

Gets a value indicating whether the given codepoint is a control character.

public static bool IsControl(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a control character; otherwise, false

IsDigit(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a decimal digit.

public static bool IsDigit(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a decimal digit; otherwise, false

IsLetter(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a letter.

public static bool IsLetter(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a letter; otherwise, false

IsLetterOrDigit(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a letter or decimal digit.

public static bool IsLetterOrDigit(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a letter or decimal digit; otherwise, false

IsLower(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a lowercase letter.

public static bool IsLower(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a lowercase letter; otherwise, false

IsMark(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a mark.

public static bool IsMark(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a symbol; otherwise, false

IsNewLine(in CodePoint)

Gets a value indicating whether the given codepoint is a new line indicator.

public static bool IsNewLine(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a new line indicator; otherwise, false

IsNonBreakingSpace(in CodePoint)

Gets a value indicating whether the given codepoint is a non-breaking space.

public static bool IsNonBreakingSpace(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a non-breaking space character; otherwise, false

IsNumber(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a number.

public static bool IsNumber(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a number; otherwise, false

IsPunctuation(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as punctuation.

public static bool IsPunctuation(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is punctuation; otherwise, false

IsSeparator(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a separator.

public static bool IsSeparator(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a separator; otherwise, false

IsSymbol(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as a symbol.

public static bool IsSymbol(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a symbol; otherwise, false

IsTabulation(in CodePoint)

Gets a value indicating whether the given codepoint is a tabulation indicator.

public static bool IsTabulation(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a tabulation indicator; otherwise, false

IsUpper(in CodePoint)

Returns a value that indicates whether the specified codepoint is categorized as an uppercase letter.

public static bool IsUpper(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a uppercase letter; otherwise, false

IsValid(int)

Returns true if value is a valid Unicode code point, i.e., is in [ U+0000..U+10FFFF ], inclusive.

public static bool IsValid(int value)

Parameters

value int

The value to evaluate.

Returns

bool

true if value represents a valid codepoint; otherwise, false

IsValid(uint)

Returns true if value is a valid Unicode code point, i.e., is in [ U+0000..U+10FFFF ], inclusive.

public static bool IsValid(uint value)

Parameters

value uint

The value to evaluate.

Returns

bool

true if value represents a valid codepoint; otherwise, false

IsVariationSelector(in CodePoint)

Gets a value indicating whether the given codepoint is a variation selector. https://en.wikipedia.org/wiki/Variation_Selectors_%28Unicode_block%29

public static bool IsVariationSelector(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a variation selector character; otherwise, false

IsWhiteSpace(in CodePoint)

Gets a value indicating whether the given codepoint is white space.

public static bool IsWhiteSpace(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a whitespace character; otherwise, false

IsZeroWidthJoiner(in CodePoint)

Gets a value indicating whether the given codepoint is a zero-width-joiner.

public static bool IsZeroWidthJoiner(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a zero-width-joiner character; otherwise, false

IsZeroWidthNonJoiner(in CodePoint)

Gets a value indicating whether the given codepoint is a zero-width-non-joiner.

public static bool IsZeroWidthNonJoiner(in CodePoint codePoint)

Parameters

codePoint CodePoint

The codepoint to evaluate.

Returns

bool

true if codePoint is a zero-width-non-joiner character; otherwise, false

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

TryGetBidiMirror(in CodePoint, out CodePoint)

Gets the codepoint representing the bidi mirror for this instance. http://www.unicode.org/reports/tr44/#Bidi_Mirrored

public static bool TryGetBidiMirror(in CodePoint codePoint, out CodePoint mirror)

Parameters

codePoint CodePoint

The code point to be mapped.

mirror CodePoint

When this method returns, contains the codepoint representing the bidi mirror for this instance; otherwise, the default value for the type of the codePoint parameter. This parameter is passed uninitialized. .

Returns

bool

true if this instance has a mirror; otherwise, false

TryGetVerticalMirror(in CodePoint, out CodePoint)

Gets the codepoint representing the vertical mirror for this instance. https://www.unicode.org/reports/tr50/#vertical_alternates

public static bool TryGetVerticalMirror(in CodePoint codePoint, out CodePoint mirror)

Parameters

codePoint CodePoint

The code point to be mapped.

mirror CodePoint

When this method returns, contains the codepoint representing the vertical mirror for this instance; otherwise, the default value for the type of the codePoint parameter. This parameter is passed uninitialized. .

Returns

bool

true if this instance has a mirror; otherwise, false

Operators

operator ==(CodePoint, CodePoint)

public static bool operator ==(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool

explicit operator CodePoint(char)

public static explicit operator CodePoint(char ch)

Parameters

ch char

Returns

CodePoint

explicit operator CodePoint(int)

public static explicit operator CodePoint(int value)

Parameters

value int

Returns

CodePoint

explicit operator CodePoint(uint)

public static explicit operator CodePoint(uint value)

Parameters

value uint

Returns

CodePoint

operator >(CodePoint, CodePoint)

public static bool operator >(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool

operator >=(CodePoint, CodePoint)

public static bool operator >=(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool

operator !=(CodePoint, CodePoint)

public static bool operator !=(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool

operator <(CodePoint, CodePoint)

public static bool operator <(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool

operator <=(CodePoint, CodePoint)

public static bool operator <=(CodePoint left, CodePoint right)

Parameters

left CodePoint
right CodePoint

Returns

bool