Cldr.Number.System.to_system

You're seeing just the function to_system, go back to Cldr.Number.System module for more information.
Link to this function

to_system(number, system_name, backend)

View Source

Specs

to_system(Cldr.Math.number_or_decimal(), atom(), Cldr.backend()) ::
  {:ok, binary()} | {:error, {module(), String.t()}}

Converts a number into the representation of a non-latin number system.

This function converts numbers to a known number system only, it does not provide number formatting.

Arguments

Returns

  • {:ok, string_of_digits} or

  • {:error, {exception, reason}}

Notes

There are two types of number systems in CLDR:

  • :numeric in which the number system defines a direct mapping between the latin digits 0..9 into a the number system equivalent. In this case, to_system/3 invokes Cldr.Number.Transliterate.transliterate_digits/3 for the given number.

  • :algorithmic in which the number system does not have the same structure as the :latn number system and therefore the conversion is done algorithmically. For CLDR the algorithm is implemented through Cldr.Rbnf rulesets. These rulesets are considered by CLDR to be less rigorous than the :numeric number systems and caution and testing for a specific use case is recommended.

Examples

iex> Cldr.Number.System.to_system 123456, :hebr, TestBackend.Cldr
{:ok, "קכ״ג׳תנ״ו"}

iex> Cldr.Number.System.to_system 123, :hans, TestBackend.Cldr
{:ok, "一百二十三"}

iex> Cldr.Number.System.to_system 123, :hant, TestBackend.Cldr
{:ok, "一百二十三"}

iex> Cldr.Number.System.to_system 123, :hansfin, TestBackend.Cldr
{:ok, "壹佰贰拾叁"}