Unicode.VerticalOrientation (Unicode v2.2.0)

Copy Markdown View Source

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

The Vertical_Orientation property describes how a codepoint is oriented when laid out in vertical text (see UAX #50). The values are :u (Upright), :r (Rotated), :tu (Transformed_Upright) and :tr (Transformed_Rotated). Codepoints without an explicit assignment default to :r.

The primary API is vertical_orientation/1 which returns the orientation of a codepoint, or the list of orientations of a string.

Summary

Functions

Returns a map of aliases for Unicode vertical orientations.

Returns the count of the codepoints with a given vertical orientation.

Returns the Unicode codepoint ranges for a given vertical orientation.

Returns the Unicode codepoint ranges for a given vertical orientation.

Returns a list of known Unicode vertical orientation names.

Returns the vertical orientation of the given binary or codepoint.

Returns the map of Unicode vertical orientations.

Functions

aliases()

Returns a map of aliases for Unicode vertical orientations.

Returns

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

Examples

iex> Unicode.VerticalOrientation.aliases() |> Map.get("upright")
:u

count(vertical_orientation)

Returns the count of the codepoints with a given vertical orientation.

Aliases are resolved by this function.

Arguments

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

Returns

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

  • :error if the vertical orientation is not known.

Examples

iex> is_integer(Unicode.VerticalOrientation.count(:u))
true

fetch(vertical_orientation)

Returns the Unicode codepoint ranges for a given vertical orientation.

Aliases are resolved by this function.

Arguments

  • vertical_orientation is any orientation 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 vertical orientation is not known.

Examples

iex> Unicode.VerticalOrientation.fetch(:u) |> elem(0)
:ok

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

get(vertical_orientation)

Returns the Unicode codepoint ranges for a given vertical orientation.

Aliases are resolved by this function.

Arguments

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

Returns

  • A list of codepoint ranges as 2-tuples.

  • nil if the vertical orientation is not known.

Examples

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

known_vertical_orientations()

Returns a list of known Unicode vertical orientation names.

Returns

  • A list of atom vertical orientation names.

Examples

iex> :tu in Unicode.VerticalOrientation.known_vertical_orientations()
true

vertical_orientation(string)

Returns the vertical orientation 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 orientation atom is returned. Codepoints without an explicit assignment return :r.

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

Examples

iex> Unicode.VerticalOrientation.vertical_orientation(?A)
:r

iex> Unicode.VerticalOrientation.vertical_orientation(0x3042)
:u

vertical_orientations()

Returns the map of Unicode vertical orientations.

Returns

  • A map where the vertical orientation is the key and a list of codepoint ranges as 2-tuples is the value.

Examples

iex> :u in Map.keys(Unicode.VerticalOrientation.vertical_orientations())
true