Class UnicodeData
The Unicode character properties text shaping needs, from Egami's own tables generated from the Unicode Character Database (version UnicodeVersion), so results never move with the .NET runtime's Unicode version.
public static class UnicodeData
- Inheritance
-
UnicodeData
- Inherited Members
Examples
// Egami's own Unicode 17.0 tables: the same answer on every runtime and machine.
Script script = UnicodeData.GetScript('\u0915'); // Devanagari
ReadOnlySpan<FontTag> tags = script.OpenTypeTags; // dev2, then deva
BidiClass bidi = UnicodeData.GetBidiClass('\u0627'); // ArabicLetter
JoiningType joining = UnicodeData.GetJoiningType('\u0628'); // DualJoining
JoiningGroup group = UnicodeData.GetJoiningGroup('\u0628'); // Beh
VerticalOrientation upright = UnicodeData.GetVerticalOrientation('\u6F22'); // Upright
EastAsianWidth width = UnicodeData.GetEastAsianWidth('\u6F22'); // Wide
bool emoji = UnicodeData.IsEmojiPresentation(0x1F600); // true
UnicodeData.TryGetBidiMirroringGlyph('(', out int mirror); // ')'
BidiPairedBracketType bracket = UnicodeData.GetBidiPairedBracketType('['); // Open
Remarks
Every lookup is a few array reads and allocates nothing. Code points must be in the range 0 to 0x10FFFF; lone surrogates are code points too (general category Surrogate).
Properties
UnicodeVersion
Gets the Unicode version of the tables: 17.0.0.
public static Version UnicodeVersion { get; }
Property Value
Methods
GetBidiClass(int)
Gets a code point's Bidi_Class (UAX #9).
public static BidiClass GetBidiClass(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- BidiClass
The class, with the default classes of unassigned code points in right-to-left blocks.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetBidiPairedBracket(int)
Gets a code point's Bidi_Paired_Bracket: the other bracket of its pair.
public static int GetBidiPairedBracket(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- int
The matching bracket, or
codePointwhen it is not a paired bracket.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetBidiPairedBracketType(int)
Gets a code point's Bidi_Paired_Bracket_Type.
public static BidiPairedBracketType GetBidiPairedBracketType(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- BidiPairedBracketType
Whether the code point opens or closes a bracket pair, or neither.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetCanonicalCombiningClass(int)
Gets a code point's Canonical_Combining_Class.
public static int GetCanonicalCombiningClass(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- int
The class, 0 to 254; 0 for starters.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetEastAsianWidth(int)
Gets a code point's East_Asian_Width (UAX #11).
public static EastAsianWidth GetEastAsianWidth(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- EastAsianWidth
The width class.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetGeneralCategory(int)
Gets a code point's General_Category.
public static UnicodeCategory GetGeneralCategory(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- UnicodeCategory
The category; OtherNotAssigned for unassigned code points.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetJoiningGroup(int)
Gets a code point's Joining_Group.
public static JoiningGroup GetJoiningGroup(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- JoiningGroup
The joining group.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetJoiningType(int)
Gets a code point's Joining_Type, with marks and format characters transparent.
public static JoiningType GetJoiningType(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- JoiningType
The joining type.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetLineBreakClass(int)
Gets a code point's Line_Break class (UAX #14).
public static LineBreakClass GetLineBreakClass(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- LineBreakClass
The class as the Unicode Character Database lists it, before UAX #14's rule LB1 resolves Ambiguous, ComplexContext and similar classes.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetScript(int)
Gets a code point's Script (UAX #24).
public static Script GetScript(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetScriptExtensions(int)
Gets a code point's Script_Extensions: the scripts it is used with.
public static ReadOnlySpan<Script> GetScriptExtensions(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- ReadOnlySpan<Script>
The scripts, in code order; just GetScript(int) when the code point has no extensions.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
GetVerticalOrientation(int)
Gets a code point's Vertical_Orientation (UAX #50).
public static VerticalOrientation GetVerticalOrientation(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
- VerticalOrientation
The orientation.
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsDefaultIgnorable(int)
Gets whether a code point has the Default_Ignorable_Code_Point property: drawn as nothing unless a font asks.
public static bool IsDefaultIgnorable(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsEmoji(int)
Gets whether a code point has the Emoji property (UTS #51).
public static bool IsEmoji(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsEmojiComponent(int)
Gets whether a code point has the Emoji_Component property: it appears inside emoji sequences.
public static bool IsEmojiComponent(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsEmojiModifier(int)
Gets whether a code point has the Emoji_Modifier property (the skin tone modifiers).
public static bool IsEmojiModifier(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsEmojiModifierBase(int)
Gets whether a code point has the Emoji_Modifier_Base property: it takes a skin tone modifier.
public static bool IsEmojiModifierBase(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsEmojiPresentation(int)
Gets whether a code point has the Emoji_Presentation property: drawn as emoji by default.
public static bool IsEmojiPresentation(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
IsExtendedPictographic(int)
Gets whether a code point has the Extended_Pictographic property, which UAX #29 uses for emoji sequences.
public static bool IsExtendedPictographic(int codePoint)
Parameters
codePointintA code point, 0 to 0x10FFFF.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.
TryGetBidiMirroringGlyph(int, out int)
Gets a code point's Bidi_Mirroring_Glyph: the character that draws its mirror image in right-to-left text.
public static bool TryGetBidiMirroringGlyph(int codePoint, out int mirror)
Parameters
codePointintA code point, 0 to 0x10FFFF.
mirrorintThe mirroring character, or
codePointwhen there is none.
Returns
Exceptions
- ArgumentOutOfRangeException
codePointis outside 0 to 0x10FFFF.