• Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • SixLabors.Fonts
      • ColorFontSupport
      • Font
      • FontCollection
      • FontCollectionExtensions
      • FontDescription
      • FontException
      • FontFamily
      • FontFamilyNotFoundException
      • FontMetrics
      • FontRectangle
      • FontStyle
      • Glyph
      • GlyphBounds
      • GlyphColor
      • GlyphLayoutMode
      • GlyphMetrics
      • GlyphMissingException
      • GlyphRendererParameters
      • GlyphType
      • HintingMode
      • HorizontalAlignment
      • HorizontalMetrics
      • IColorGlyphRenderer
      • IFontCollection
      • IGlyphRenderer
      • IGlyphRendererExtensions
      • IMetricsHeader
      • IReadOnlyFontCollection
      • IReadOnlySystemFontCollection
      • InvalidFontFileException
      • InvalidFontTableException
      • KerningMode
      • LayoutMode
      • LayoutModeExtensions
      • MissingFontTableException
      • SystemFonts
      • TextAlignment
      • TextAttributes
      • TextDecorations
      • TextDirection
      • TextJustification
      • TextMeasurer
      • TextOptions
      • TextRenderer
      • TextRun
      • VerticalAlignment
      • VerticalMetrics
      • WordBreaking
    • SixLabors.Fonts.Tables.AdvancedTypographic
      • FeatureTags
      • GlyphClassDef
      • Tag
    • SixLabors.Fonts.Tables.TrueType
      • TrueTypeGlyphMetrics
    • SixLabors.Fonts.Unicode
      • ArabicJoiningClass
      • ArabicJoiningGroup
      • ArabicJoiningType
      • BidiCharacterType
      • BidiClass
      • BidiPairedBracketType
      • CodePoint
      • GraphemeClusterClass
      • IndicPositionalCategory
      • IndicSyllabicCategory
      • LineBreakClass
      • MemoryExtensions
      • ScriptClass
      • SpanCodePointEnumerator
      • SpanGraphemeEnumerator
      • VerticalOrientationType
    • SixLabors.Fonts.WellKnownIds
      • KnownNameIds

    Struct CodePoint

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

    Implements
    IComparable
    IComparable<CodePoint>
    IEquatable<CodePoint>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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

    CodePoint(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 value represents a UTF-16 surrogate code point U+D800..U+DFFF, inclusive.

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

    Declaration
    public CodePoint(int value)
    Parameters
    Type Name Description
    int value

    The value to create the codepoint.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If value does not represent a value Unicode scalar value.

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

    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

    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.

    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:

    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.

    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 other parameter; otherwise, false.

    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 obj and this instance are the same type and represent the same value; otherwise, false.

    Overrides
    ValueType.Equals(object)

    GetBidiClass(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
    ValueType.GetHashCode()

    GetLineBreakClass(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

    The 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

    true if codePoint is a control character; otherwise, false

    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

    true if codePoint is a decimal digit; otherwise, false

    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

    true if codePoint is a letter; otherwise, false

    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 codePoint is a letter or decimal digit; otherwise, false

    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

    true if codePoint is a lowercase letter; otherwise, false

    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

    true if codePoint is a symbol; otherwise, false

    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

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

    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 codePoint is a non-breaking space character; otherwise, false

    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

    true if codePoint is a number; otherwise, false

    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

    true if codePoint is punctuation; otherwise, false

    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

    true if codePoint is a separator; otherwise, false

    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

    true if codePoint is a symbol; otherwise, false

    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 codePoint is a tabulation indicator; otherwise, false

    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

    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.

    Declaration
    public static bool IsValid(int value)
    Parameters
    Type Name Description
    int value

    The value to evaluate.

    Returns
    Type Description
    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.

    Declaration
    public static bool IsValid(uint value)
    Parameters
    Type Name Description
    uint value

    The value to evaluate.

    Returns
    Type Description
    bool

    true if value represents a valid codepoint; otherwise, false

    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 codePoint is a variation selector character; otherwise, false

    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 codePoint is a whitespace character; otherwise, false

    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 codePoint is a zero-width-joiner character; otherwise, false

    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 codePoint is a zero-width-non-joiner character; otherwise, false

    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
    ValueType.ToString()

    TryGetBidiMirror(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 codePoint parameter. This parameter is passed uninitialized. .

    Returns
    Type Description
    bool

    true if this instance has a mirror; otherwise, false

    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 codePoint parameter. This parameter is passed uninitialized. .

    Returns
    Type Description
    bool

    true if this instance has a mirror; otherwise, false

    Operators

    operator ==(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

    Implements

    IComparable
    IComparable<T>
    IEquatable<T>
    In this article
    Back to top Generated by DocFX