# `Unicode.Age`
[🔗](https://github.com/elixir-unicode/unicode/blob/v2.2.0/lib/unicode/property/age.ex#L1)

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

The `Age` property records the version of Unicode in which a codepoint was first assigned. The value is an atom formed from the version number, for example `:"1.1"` or `:"15.0"`.

The primary API is `age/1` which returns the age of a codepoint, or the list of ages of a string. The functions `fetch/1`, `get/1` and `count/1` provide introspection of the codepoint ranges belonging to a given age.

# `age`

Returns the age 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 age atom is returned. Unassigned codepoints return `:unassigned`.

* For a binary, a list of the distinct ages of the codepoints in the binary is returned.

### Examples

    iex> Unicode.Age.age(?A)
    :"1.1"

    iex> Unicode.Age.age(0x0378)
    :unassigned

# `ages`

Returns the map of Unicode ages.

### Returns

* A map where the age (as an atom version number) is the key and a list of codepoint ranges as 2-tuples is the value.

### Examples

    iex> Unicode.Age.ages() |> Map.get(:"1.1") |> hd()
    {0, 501}

# `aliases`

Returns a map of aliases for Unicode ages.

An alias is an alternative name for referring to an age. `PropertyValueAliases.txt`
gives each age a `V<major>_<minor>` alias, so `"V18_0"` is an alias for `:"18.0"`.
Alias keys are normalised by downcasing and removing whitespace and underscores,
the same normalisation `fetch/1` and `get/1` apply to their argument, so `"V18_0"`
is stored and looked up as `"v180"`. Aliases are resolved by `fetch/1` and `get/1`.

### Returns

* A map of age aliases to the canonical age name.

### Examples

    iex> Unicode.Age.aliases() |> Map.get("v11")
    :"1.1"

    iex> Unicode.Age.fetch("V18_0") == Unicode.Age.fetch("18.0")
    true

# `count`

Returns the count of the codepoints assigned in a given age.

### Arguments

* `age` is any known age, as an atom or string.

### Returns

* A non-negative integer count of the codepoints in the age.

* `:error` if the age is not known.

### Examples

    iex> Unicode.Age.count(:"1.1")
    33979

# `fetch`

Returns the Unicode codepoint ranges for a given age.

### Arguments

* `age` is any known age, as an atom or string.

### Returns

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

* `:error` if the age is not known.

### Examples

    iex> Unicode.Age.fetch(:"1.1") |> elem(0)
    :ok

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

# `get`

Returns the Unicode codepoint ranges for a given age.

### Arguments

* `age` is any known age, as an atom or string.

### Returns

* A list of codepoint ranges as 2-tuples.

* `nil` if the age is not known.

### Examples

    iex> Unicode.Age.get(:"1.1") |> hd()
    {0, 501}

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

# `known_ages`

Returns a list of known Unicode ages.

### Returns

* A list of atom version numbers.

### Examples

    iex> :"1.1" in Unicode.Age.known_ages()
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
