Unicode.BidiPairedBracketType (Unicode v2.2.0)

Copy Markdown View Source

Functions to introspect the Unicode Bidi_Paired_Bracket_Type property for binaries (Strings) and codepoints.

The Bidi_Paired_Bracket_Type property identifies the bracket pairs used by the bidirectional algorithm (see UAX #9). The values are :open and :close; all other codepoints have the value :none.

The primary API is bidi_paired_bracket_type/1 which returns the type of a codepoint, or the list of types of a string.

Summary

Functions

Returns a map of aliases for Unicode bidi paired bracket types.

Returns the bidi paired bracket type of the given binary or codepoint.

Returns the map of Unicode bidi paired bracket types.

Returns the count of the codepoints with a given bidi paired bracket type.

Returns the Unicode codepoint ranges for a given bidi paired bracket type.

Returns the Unicode codepoint ranges for a given bidi paired bracket type.

Returns a list of known Unicode bidi paired bracket type names.

Functions

aliases()

Returns a map of aliases for Unicode bidi paired bracket types.

Returns

  • A map where the alias string is the key and the type is the value.

Examples

iex> Unicode.BidiPairedBracketType.aliases() |> Map.get("o")
:open

bidi_paired_bracket_type(string)

Returns the bidi paired bracket type of the given binary or codepoint.

Arguments

  • string_or_codepoint is either a binary (String) or a codepoint in the range 0..0x10FFFF.

Returns

  • For a codepoint, a single type atom is returned. Codepoints that are not brackets return :none.

  • For a binary, a list of the distinct types of the codepoints in the binary is returned.

Examples

iex> Unicode.BidiPairedBracketType.bidi_paired_bracket_type(?\()
:open

iex> Unicode.BidiPairedBracketType.bidi_paired_bracket_type(?\))
:close

iex> Unicode.BidiPairedBracketType.bidi_paired_bracket_type(?A)
:none

bidi_paired_bracket_types()

Returns the map of Unicode bidi paired bracket types.

Returns

  • A map where the type (:open or :close) is the key and a list of codepoint ranges as 2-tuples is the value.

Examples

iex> Unicode.BidiPairedBracketType.bidi_paired_bracket_types() |> Map.keys() |> Enum.sort()
[:close, :none, :open]

count(type)

Returns the count of the codepoints with a given bidi paired bracket type.

Aliases are resolved by this function.

Arguments

  • type is any type name or alias, as an atom or string.

Returns

  • A non-negative integer count of the codepoints with the type.

  • :error if the type is not known.

Examples

iex> is_integer(Unicode.BidiPairedBracketType.count(:open))
true

fetch(type)

Returns the Unicode codepoint ranges for a given bidi paired bracket type.

Aliases are resolved by this function.

Arguments

  • type is any type name or alias, as an atom or string.

Returns

  • {:ok, range_list} where range_list is a list of codepoint ranges as 2-tuples.

  • :error if the type is not known.

Examples

iex> Unicode.BidiPairedBracketType.fetch(:open) |> elem(0)
:ok

iex> Unicode.BidiPairedBracketType.fetch(:invalid)
:error

get(type)

Returns the Unicode codepoint ranges for a given bidi paired bracket type.

Aliases are resolved by this function.

Arguments

  • type is any type name or alias, as an atom or string.

Returns

  • A list of codepoint ranges as 2-tuples.

  • nil if the type is not known.

Examples

iex> Unicode.BidiPairedBracketType.get(:invalid)
nil

known_bidi_paired_bracket_types()

Returns a list of known Unicode bidi paired bracket type names.

Returns

  • A list of atom type names.

Examples

iex> :open in Unicode.BidiPairedBracketType.known_bidi_paired_bracket_types()
true