Last active
February 25, 2025 14:11
-
-
Save LemonyPie/eb27b177cea4586947061c6bb3945cc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright (C) 2009 The Libphonenumber Authors | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
@author: Shaopeng Jia | |
Metadata on Phone Number Plan and formatting rules | |
Note: Territories are in alphabetical order by their IDs, which are based on CLDR | |
two-letter region codes (or are set to "001" for non-geographical entities, which | |
represents "World" in the UN M.49 standard). The country names in the comments are the | |
official short names in English according to CLDR. | |
For more information on what each element represents, see | |
resources/phonemetadata.proto | |
Note that if you want to add validation metadata, the generalDesc nationalNumberPattern must be | |
provided. If this is missing, then the country will be considered to have no more specific | |
phone-number type metadata (fixedLine, mobile etc) and hence only basic validation rules | |
(numbers should be between 3 and 15 digits long) will be applied. | |
If adding an element for a non-geographical entity, please add an example number element to the | |
general description. | |
Country code, international and national prefix information main source: | |
http://www.itu.int/pub/T-SP-E.164C-2011 | |
Known omissions: | |
* French Southern Territories (id="TF" countryCode="262") | |
This is not covered due to lack of information about its numbering plan. It has 140 | |
temporary inhabitants. | |
* Pitcairn Island (id="PN") | |
This is not supported since evidence seems to be that the 50 inhabitants use satellite | |
phones. | |
See also: | |
https://github.com/google/libphonenumber/blob/master/FAQ.md#unsupported | |
--> | |
<!DOCTYPE phoneNumberMetadata [ | |
<!ELEMENT phoneNumberMetadata (territories)> | |
<!ELEMENT territories (territory+)> | |
<!ELEMENT territory (references?, availableFormats?, generalDesc, noInternationalDialling?, | |
fixedLine?, mobile?, pager?, tollFree?, premiumRate?, | |
sharedCost?, personalNumber?, voip?, uan?, voicemail?)> | |
<!ELEMENT references (sourceUrl+)> | |
<!ELEMENT generalDesc (nationalNumberPattern)> | |
<!ELEMENT noInternationalDialling (possibleLengths, nationalNumberPattern)> | |
<!ELEMENT fixedLine (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT mobile (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT pager (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT tollFree (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT premiumRate (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT sharedCost (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT personalNumber (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT voip (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT uan (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT voicemail (possibleLengths, exampleNumber, nationalNumberPattern)> | |
<!ELEMENT sourceUrl (#PCDATA)> | |
<!ELEMENT availableFormats (numberFormat+)> | |
<!ELEMENT nationalNumberPattern (#PCDATA)> | |
<!ELEMENT exampleNumber (#PCDATA)> | |
<!ELEMENT numberFormat (leadingDigits*, format, intlFormat*)> | |
<!ELEMENT format (#PCDATA)> | |
<!ELEMENT intlFormat (#PCDATA)> | |
<!ELEMENT leadingDigits (#PCDATA)> | |
<!ELEMENT possibleLengths EMPTY> | |
<!ATTLIST territory id CDATA #REQUIRED> | |
<!ATTLIST territory countryCode CDATA #REQUIRED> | |
<!ATTLIST territory mainCountryForCode (true) #IMPLIED> | |
<!ATTLIST territory leadingDigits CDATA #IMPLIED> | |
<!ATTLIST territory preferredInternationalPrefix CDATA #IMPLIED> | |
<!ATTLIST territory internationalPrefix CDATA #IMPLIED> | |
<!ATTLIST territory nationalPrefix CDATA #IMPLIED> | |
<!ATTLIST territory nationalPrefixForParsing CDATA #IMPLIED> | |
<!ATTLIST territory nationalPrefixTransformRule CDATA #IMPLIED> | |
<!ATTLIST territory preferredExtnPrefix CDATA #IMPLIED> | |
<!ATTLIST territory nationalPrefixFormattingRule CDATA #IMPLIED> | |
<!ATTLIST territory nationalPrefixOptionalWhenFormatting (true) #IMPLIED> | |
<!ATTLIST territory carrierCodeFormattingRule CDATA #IMPLIED> | |
<!ATTLIST territory mobileNumberPortableRegion (true) #IMPLIED> | |
<!ATTLIST possibleLengths national CDATA #REQUIRED> | |
<!ATTLIST possibleLengths localOnly CDATA #IMPLIED> | |
<!ATTLIST numberFormat nationalPrefixFormattingRule CDATA #IMPLIED> | |
<!ATTLIST numberFormat nationalPrefixOptionalWhenFormatting (true) #IMPLIED> | |
<!ATTLIST numberFormat carrierCodeFormattingRule CDATA #IMPLIED> | |
<!ATTLIST numberFormat pattern CDATA #REQUIRED> | |
]> | |
<phoneNumberMetadata> | |
<territories> | |
<territory id="US" mainCountryForCode="true" countryCode="1" internationalPrefix="011" | |
nationalPrefix="1" mobileNumberPortableRegion="true"> | |
<availableFormats> | |
<!-- 310-xxxx (7 digit) UAN numbers . --> | |
<numberFormat pattern="(\d{3})(\d{4})" nationalPrefixOptionalWhenFormatting="true"> | |
<leadingDigits>310</leadingDigits> | |
<format>$1-$2</format> | |
</numberFormat> | |
<numberFormat pattern="(\d{3})(\d{4})"> | |
<leadingDigits> | |
[24-9]| | |
3(?: | |
[02-9]| | |
1[1-9] | |
) | |
</leadingDigits> | |
<format>$1-$2</format> | |
<intlFormat>NA</intlFormat> | |
</numberFormat> | |
<!-- A different pattern is used when formatting internationally, as the area code is no | |
longer optional and should not be in brackets. --> | |
<numberFormat pattern="(\d{3})(\d{3})(\d{4})" nationalPrefixOptionalWhenFormatting="true"> | |
<leadingDigits>[2-9]</leadingDigits> | |
<format>($1) $2-$3</format> | |
<intlFormat>$1-$2-$3</intlFormat> | |
</numberFormat> | |
</availableFormats> | |
<generalDesc> | |
<nationalNumberPattern> | |
[2-9]\d{9}| | |
3\d{6} | |
</nationalNumberPattern> | |
</generalDesc> | |
<fixedLine> | |
<possibleLengths national="10" localOnly="7"/> | |
<exampleNumber>2015550123</exampleNumber> | |
<nationalNumberPattern> | |
(?: | |
3052(?: | |
0[0-8]| | |
[1-9]\d | |
)| | |
5056(?: | |
[0-35-9]\d| | |
4[468] | |
) | |
)\d{4}| | |
(?: | |
2742| | |
305[3-9]| | |
472[247-9]| | |
505[2-57-9]| | |
983[2-47-9] | |
)\d{6}| | |
(?: | |
2(?: | |
0[1-9]| | |
1[02-9]| | |
2[03-9]| | |
3[14569]| | |
4[02689]| | |
5[0-46]| | |
6[02-47-9]| | |
7[0269]| | |
8[1349] | |
)| | |
3(?: | |
0[1-46-9]| | |
1[02-9]| | |
2[0135-79]| | |
3[0-24679]| | |
4[0135-7]| | |
5[0-247]| | |
6[013-57-9]| | |
8[0256] | |
)| | |
4(?: | |
0[1-9]| | |
1[02-9]| | |
2[3-58]| | |
3[0-24578]| | |
4[0-3578]| | |
5[78]| | |
6[3489]| | |
7[0-4589]| | |
8[034] | |
)| | |
5(?: | |
0[1-9]| | |
1[02-9]| | |
20| | |
3[0149]| | |
4[018]| | |
5[179]| | |
6[1-47]| | |
7[0-59]| | |
8[0-24-7] | |
)| | |
6(?: | |
0[1-35-9]| | |
1[024-9]| | |
2[023689]| | |
3[01369]| | |
4[015-79]| | |
5[0167-9]| | |
6[0-2479]| | |
7[0-289]| | |
8[0-49] | |
)| | |
7(?: | |
0[1-9]| | |
1[2-9]| | |
2[014-8]| | |
3[0-247]| | |
4[0237]| | |
5[3478]| | |
6[023579]| | |
7[0-589]| | |
8[124-7] | |
)| | |
8(?: | |
0[0-9]| | |
1[02-9]| | |
2[0568]| | |
3[0-3589]| | |
4[03-578]| | |
5[04-9]| | |
6[02-9]| | |
7[0236-9]| | |
88 | |
)| | |
9(?: | |
0[1-9]| | |
1[02-9]| | |
2[0589]| | |
3[0146-9]| | |
4[0-357-9]| | |
5[12469]| | |
7[0-389]| | |
8[04-69] | |
) | |
)[2-9]\d{6} | |
</nationalNumberPattern> | |
</fixedLine> | |
<mobile> | |
<possibleLengths national="10" localOnly="7"/> | |
<exampleNumber>2015550123</exampleNumber> | |
<nationalNumberPattern> | |
(?: | |
3052(?: | |
0[0-8]| | |
[1-9]\d | |
)| | |
5056(?: | |
[0-35-9]\d| | |
4[468] | |
) | |
)\d{4}| | |
(?: | |
2742| | |
305[3-9]| | |
472[247-9]| | |
505[2-57-9]| | |
983[2-47-9] | |
)\d{6}| | |
(?: | |
2(?: | |
0[1-35-9]| | |
1[02-9]| | |
2[03-57-9]| | |
3[1459]| | |
4[08]| | |
5[1-46]| | |
6[0279]| | |
7[0269]| | |
8[13] | |
)| | |
3(?: | |
0[1-47-9]| | |
1[02-9]| | |
2[0135-79]| | |
3[0-24679]| | |
4[167]| | |
5[0-2]| | |
6[01349]| | |
8[056] | |
)| | |
4(?: | |
0[124-9]| | |
1[02-579]| | |
2[3-5]| | |
3[0245]| | |
4[023578]| | |
58| | |
6[349]| | |
7[0589]| | |
8[04] | |
)| | |
5(?: | |
0[1-47-9]| | |
1[0235-8]| | |
20| | |
3[0149]| | |
4[01]| | |
5[179]| | |
6[1-47]| | |
7[0-5]| | |
8[0256] | |
)| | |
6(?: | |
0[1-35-9]| | |
1[024-9]| | |
2[03689]| | |
3[016]| | |
4[0156]| | |
5[01679]| | |
6[0-279]| | |
78| | |
8[0-29] | |
)| | |
7(?: | |
0[1-46-8]| | |
1[2-9]| | |
2[04-8]| | |
3[0-247]| | |
4[037]| | |
5[47]| | |
6[02359]| | |
7[0-59]| | |
8[156] | |
)| | |
8(?: | |
0[1-68]| | |
1[02-8]| | |
2[068]| | |
3[0-2589]| | |
4[03578]| | |
5[046-9]| | |
6[02-5]| | |
7[028] | |
)| | |
9(?: | |
0[1346-9]| | |
1[02-9]| | |
2[0589]| | |
3[0146-8]| | |
4[01357-9]| | |
5[12469]| | |
7[0-389]| | |
8[04-69] | |
) | |
)[2-9]\d{6} | |
</nationalNumberPattern> | |
</mobile> | |
<tollFree> | |
<possibleLengths national="10"/> | |
<exampleNumber>8002345678</exampleNumber> | |
<nationalNumberPattern> | |
8(?: | |
00| | |
33| | |
44| | |
55| | |
66| | |
77| | |
88 | |
)[2-9]\d{6} | |
</nationalNumberPattern> | |
</tollFree> | |
<premiumRate> | |
<possibleLengths national="10"/> | |
<exampleNumber>9002345678</exampleNumber> | |
<nationalNumberPattern>900[2-9]\d{6}</nationalNumberPattern> | |
</premiumRate> | |
<!-- https://www.nationalnanpa.com/number_resource_info/5XX_codes.html --> | |
<personalNumber> | |
<possibleLengths national="10"/> | |
<exampleNumber>5002345678</exampleNumber> | |
<nationalNumberPattern> | |
52(?: | |
3(?: | |
[2-46-9][02-9]\d| | |
5(?: | |
[02-46-9]\d| | |
5[0-46-9] | |
) | |
)| | |
4(?: | |
[2-478][02-9]\d| | |
5(?: | |
[034]\d| | |
2[024-9]| | |
5[0-46-9] | |
)| | |
6(?: | |
0[1-9]| | |
[2-9]\d | |
)| | |
9(?: | |
[05-9]\d| | |
2[0-5]| | |
49 | |
) | |
) | |
)\d{4}| | |
52[34][2-9]1[02-9]\d{4}| | |
5(?: | |
00| | |
2[125-9]| | |
33| | |
44| | |
66| | |
77| | |
88 | |
)[2-9]\d{6} | |
</nationalNumberPattern> | |
</personalNumber> | |
<voip> | |
<possibleLengths national="10" localOnly="7"/> | |
<exampleNumber>3052090123</exampleNumber> | |
<nationalNumberPattern>305209\d{4}</nationalNumberPattern> | |
</voip> | |
</territory> | |
</territories> | |
</phoneNumberMetadata> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment