UnicodeScripts Class

Provides access to the Unicode Script and Script_Extensions character properties.

public static class UnicodeScripts

Properties

NameDescription
MaxScriptExtensionCountGets the greatest number of scripts UnicodeScripts.GetScriptExtensions writes for a code point.

MaxScriptExtensionCount

UnicodeScripts.cs

Gets the greatest number of scripts UnicodeScripts.GetScriptExtensions writes for a code point.

public static int MaxScriptExtensionCount { get; }

Property value

int

Methods

NameDescription
GetIso15924Code(UnicodeScript)Gets the four-letter ISO 15924 code of a script, such as Latn.
GetScript(int)Gets the script of a code point.
GetScript(Rune)Gets the script of a rune.
GetScriptExtensions(int, Span<UnicodeScript>)Gets the Script_Extensions of a code point: the scripts it is used with.
HasScriptExtension(int, UnicodeScript)Determines whether a script is one of the Script_Extensions of a code point.
TryParseScript(ReadOnlySpan<char>, UnicodeScript)Gets the script that a name of the Script property designates, such as Latin or Latn.

GetIso15924Code(UnicodeScript)

UnicodeScripts.cs

Gets the four-letter ISO 15924 code of a script, such as Latn.

public static string GetIso15924Code(UnicodeScript script)

Parameters

script UnicodeScript
The script.

Returns

string The code; Zzzz for UnicodeScript.Unknown and for a value that is not defined.

GetScript overloads

GetScript(int)

UnicodeScripts.cs

Gets the script of a code point.

public static UnicodeScript GetScript(int codePoint)
Parameters
codePoint int
The code point.
Returns

UnicodeScript The script, or UnicodeScript.Unknown when the code point has no assigned script.

GetScript(Rune)

UnicodeScripts.cs

Gets the script of a rune.

public static UnicodeScript GetScript(Rune rune)
Parameters
rune Rune
The rune.
Returns

UnicodeScript The script, or UnicodeScript.Unknown when the rune has no assigned script.

GetScriptExtensions(int, Span<UnicodeScript>)

UnicodeScripts.cs

Gets the Script_Extensions of a code point: the scripts it is used with.

public static int GetScriptExtensions(int codePoint, Span<UnicodeScript> destination)

Parameters

codePoint int
The code point.
destination Span<UnicodeScript>
The buffer that receives the scripts, in increasing numeric value.

Returns

int The number of scripts written. It is 1, the script of UnicodeScripts.GetScript, for a code point that has no explicit Script_Extensions value.

Exceptions

ArgumentException
destination is too small. UnicodeScripts.MaxScriptExtensionCount elements are always enough.

See also

HasScriptExtension(int, UnicodeScript)

UnicodeScripts.cs

Determines whether a script is one of the Script_Extensions of a code point.

public static bool HasScriptExtension(int codePoint, UnicodeScript script)

Parameters

codePoint int
The code point.
script UnicodeScript
The script.

Returns

bool true when the code point is used with the script.

TryParseScript(ReadOnlySpan<char>, UnicodeScript)

UnicodeScripts.cs

Gets the script that a name of the Script property designates, such as Latin or Latn.

public static bool TryParseScript(ReadOnlySpan<char> name, out UnicodeScript script)

Parameters

name ReadOnlySpan<char>
The long name, the short name (the ISO 15924 code) or another alias of the script, as listed in PropertyValueAliases.txt.
script UnicodeScript
The script, when the method returns true.

Returns

bool true when the name is a name of a script.

Remarks

The comparison is ordinal: the loose matching of UAX #44 (ignoring case, spaces, hyphens and underscores) is not applied. Unknown and Zzzz designate UnicodeScript.Unknown.