Skip to main content

Module phones

Module phones 

Source
Expand description

Phone numbers, compared rather than rewritten: “04 65 71 12 34”, “04.65.71.12.34”, “+33 4 65 71 12 34”, “+33 (0)4 65 71 12 34” and “0033465711234” are one number, written five ways. Each number gets a key, its international form (E.164, ITU-T) with its extension, and two numbers with one key are the same; what the card says stays as it was written.

A number written without its country is read as the country chosen in the Contacts settings, else the country of the system’s locale. A small table knows how the usual countries write their numbers at home: the trunk prefix dropped in the international form (“0” in most of Europe, “1” in North America, none in Spain or Italy) and how long a number is, so that a short code (“3631”, “112”) is never given a country. Values with letters (“1-555-SIOUL”), stars and hashes (“*#06#”) are compared as written. The rules are those of each country’s numbering plan, as the ITU publishes them (https://www.itu.int/oth/T0202); libphonenumber knows every country but weighs megabytes, for what this table does for the usual ones.

Structs§

Region
How a country writes its numbers at home.

Constants§

REGIONS
The countries known here (docs/client.md, “Duplicates”).

Functions§

chosen
The country chosen in the settings (setting, an ISO code), else the usual one. A code not known here reads numbers without a country as they are written.
digits_of 🔒
The digits of a number, with “+” first when it is written internationally; none when it holds anything a number does not (letters, “*”, “#”).
drops_written_trunk 🔒
The country codes whose numbers never start with 0: written “+33 06…”, the 0 is the trunk prefix kept by mistake. Italy’s 0 is part of the number.
french 🔒
french_overseas 🔒
The French plan’s overseas numbers, by the three digits after the 0: Réunion and Mayotte share +262, Guadeloupe (with Saint-Martin and Saint-Barthélemy) +590, French Guiana +594, Martinique +596 (ARCEP).
is_international
Whether a number is written in its international form, as people write it: “+33 6…”.
is_spacing 🔒
Characters that only space a number out: spaces of every width, dots, dashes, slashes; and the invisible marks of writing direction phones put around numbers (iOS writes “\u{202a}+33 6…\u{202c}”).
is_whole
Whether a key stands for a whole number (not a short code), so that two cards sharing it may be one person.
key
A number’s key, to compare it: its international form (“+33465711234”), its extension after “;ext=”. A number written without its country takes region’s; a short code and a value that is not a number are compared as written, spaces aside. Never shown, never written to a card.
number_key 🔒
The number’s own key, without the extension; none when it is not a number.
region 🔒
region_named
A country of the table, by its ISO code (“fr” too).
region_of_locale
The country a locale names: “fr_FR.UTF-8” → France, “en-GB” → the United Kingdom; none for a language alone (“fr”), “C” or a country not known here.
split_extension 🔒
The extension at the end of a number, after its marker: “poste 12”, “ext. 12”, “x12”, “#12”, “,12”, “;ext=12”. Returns the number before it and the digits.
usual_region
The country numbers without one are read as, unless the settings say: the system’s locale (LC_ALL, LC_TELEPHONE, LANG), else Sioul’s language’s own (language_locale, “fr_FR” for French).
without_written_trunk 🔒
“+330465711234” → “+33465711234”: a trunk 0 written after a country code that has none.
without_zero_in_parentheses 🔒
“+33 (0)6…”: the trunk prefix some write in parentheses after the country code, out; Italy’s 0 belongs to the number and stays.