libphonenumber-js 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -75
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/libphonenumber-js)
|
|
5
5
|
[](https://coveralls.io/r/catamphetamine/libphonenumber-js?branch=master)
|
|
6
6
|
|
|
7
|
-
A simpler and smaller rewrite of Google Android's [`libphonenumber`](https://github.com/google/libphonenumber/) library in javascript/
|
|
7
|
+
A simpler and smaller rewrite of Google Android's [`libphonenumber`](https://github.com/google/libphonenumber/) library in javascript/typescript.
|
|
8
8
|
|
|
9
9
|
Parse and format personal phone numbers.
|
|
10
10
|
|
|
@@ -12,11 +12,11 @@ Parse and format personal phone numbers.
|
|
|
12
12
|
|
|
13
13
|
If you’re trying to build a React component with it, take a look at [`react-phone-number-input`](https://www.npmjs.com/package/react-phone-number-input).
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## libphonenumber
|
|
16
16
|
|
|
17
|
-
Google's [`libphonenumber`](https://github.com/googlei18n/libphonenumber) is an ultimate phone number formatting and parsing library developed by Google for [Android](https://en.wikipedia.org/wiki/Android_(operating_system)) phones. It is written in C++ and Java, and, while it has an [official autogenerated javascript port](https://github.com/googlei18n/libphonenumber/tree/master/javascript), that port is tightly coupled to Google's `closure` javascript framework, and
|
|
17
|
+
Google's [`libphonenumber`](https://github.com/googlei18n/libphonenumber) is an ultimate phone number formatting and parsing library developed by Google for [Android](https://en.wikipedia.org/wiki/Android_(operating_system)) phones. It is written in C++ and Java, and, while it has an [official autogenerated javascript port](https://github.com/googlei18n/libphonenumber/tree/master/javascript), that port is tightly coupled to Google's `closure` javascript framework, and when compiled into a [bundle](https://github.com/ruimarinho/google-libphonenumber), the total weight becomes about 550 kB (350 kB code + 200 kB metadata).
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
`libphonenumber-js` works around the bundle size issue by stripping down both code and metadata: the code was rewritten in javascript/typescript from scratch, and a developer can now choose which parts of metadata to include.
|
|
20
20
|
|
|
21
21
|
<!-- That's what `libphonenumber-js` is about: I started off from scratch, decyphering Google's code and figuring out how this whole machinery works, through trial and error, with several years of hacking around, receiving bug reports from other developers — eventually, it has reached a state when it can be assumed production-ready. -->
|
|
22
22
|
|
|
@@ -24,39 +24,44 @@ With many websites today asking for user's phone number, the internet could bene
|
|
|
24
24
|
One part of me was curious about how all this phone number parsing and formatting machinery worked, and another part of me was curious if there was a way to reduce those 530 kilobytes to something more reasonable while also getting rid of all the unnecessary bulk and rewriting it all in pure javascript. The resulting library does everything a modern web application needs while maintaining a much smaller size of about 130 kilobytes.
|
|
25
25
|
-->
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
<details>
|
|
28
|
+
|
|
29
|
+
<summary>Here's a full comparison to Google's <code>libphonenumber</code> for those who're interested.</summary>
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
######
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
* Smaller footprint: `145 kB` (65 kB code + 80 kB sufficient metadata) vs the original Google's `550 kB` (350 kB code + 200 kB full metadata).
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
* Comes with TypeScript definitions.
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
* Can search for phone numbers in text. Google's autogenerated javascript port doesn't provide such feature for some reason.
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
* Focuses on parsing and formatting personal phone numbers while skipping any other "special" cases like:
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
* Emergency phone numbers like `911`.
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
* ["Short codes"](https://www.tatango.com/blog/sms-short-codes-what-every-business-needs-to-know/) — short SMS-only numbers like `12345`.
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
* Numbers starting with an `*`. For example, `*555` is used in New Zeland to report non-urgent traffic incidents. Or, in Israel, certain advertising numbers start with a `*`.
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
* Australian [`13`-smart](https://github.com/catamphetamine/libphonenumber-js/issues/400) numbers, which are a "catchy" "short" form of regular "landline" numbers and are mainly used in [advertisement](https://www.youtube.com/watch?v=Y0HchzE-7rM).
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
* Alphabetic phone numbers like `1-800-GOT-MILK`. People don't input their phone numbers like that. It was only used in advertisement in the days of push-button telephones.
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
* "Two-in-one" phone numbers with "combined" extensions like `(530) 583-6985 x302/x2303`. Phone numbers like that actually represent two separate phone numbers, so it's not clear which one to pick or how to return both at the same time.
|
|
50
52
|
|
|
51
|
-
*
|
|
53
|
+
* Local numbers with the "area code" omitted. For example, when dialing phone numbers within the same "area", people sometimes skip the "area code", and dial, say, just `456-789` instead of proper `(123) 456-789`. This all is considered a relic of the past. In the modern world, there're no "local areas" and anyone could call everyone else around the world.
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
* Doesn't provide "geolocation" feature when it can tell a city by a phone number.
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
* Doesn't use hyphens or brackets when formatting phone numbers in international format. Instead, whitespace is used. The rationale is that brackets aren't relevant in international context because there're no "local areas", and hyphens aren't used because whitespace just looks cleaner.
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
* Doesn't set `.country` to `"001"` when parsing ["non-geographic"](#non-geographic) phone numbers, like mobile satellite communications services. Instead, `.country` is set to `undefined` in those cases, and instead a developer can call `.isNonGeographic()` method of the `PhoneNumber` instance to find out whether the parsed phone number is a "non-geographic" one.
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
* Doesn't provide the equivalent of `libphonenumber`'s `formatNumberForMobileDialing()` function that formats a number for dialing from a mobile phone within the same country. This feature may be required for dialing local numbers from a mobile phone in some countries like Brazil or Colombia where they require adding ["carrier codes"](https://www.bandwidth.com/glossary/carrier-identification-code-cic/) when making such calls. Since `libphonenumber-js` is not a dialing library (we're not Android phone operaing system), it doesn't prepend any "carrier codes" when formatting such phone numbers, though it does parse such "carrier codes" correctly.
|
|
62
|
+
|
|
63
|
+
* Fixed a small [bug](https://issuetracker.google.com/issues/335892662) when Canadian numbers `+1310xxxx` wheren't considered possible.
|
|
64
|
+
</details>
|
|
60
65
|
|
|
61
66
|
<!-- (Australia, Bolivia, Brazil, China, Colombia, Croatia, Faroe Islands, South Korea, Liechtenstein, Luxembourg, Venezuela) -->
|
|
62
67
|
|
|
@@ -76,16 +81,8 @@ One part of me was curious about how all this phone number parsing and formattin
|
|
|
76
81
|
|
|
77
82
|
## Install
|
|
78
83
|
|
|
79
|
-
via [npm](https://npmjs.org/)
|
|
80
|
-
|
|
81
84
|
```sh
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
via [yarn](https://yarnpkg.com)
|
|
86
|
-
|
|
87
|
-
```sh
|
|
88
|
-
$ yarn add libphonenumber-js
|
|
85
|
+
npm install libphonenumber-js --save
|
|
89
86
|
```
|
|
90
87
|
|
|
91
88
|
Alternatively, one could include it on a web page [directly](#cdn) via a `<script/>` tag.
|
|
@@ -161,7 +158,7 @@ if (phoneNumber) {
|
|
|
161
158
|
phoneNumber.number === '+78005553535'
|
|
162
159
|
phoneNumber.isPossible() === true
|
|
163
160
|
phoneNumber.isValid() === true
|
|
164
|
-
//
|
|
161
|
+
// `.getType()` only works when import from 'libphonenumber-js/max'
|
|
165
162
|
phoneNumber.getType() === 'TOLL_FREE'
|
|
166
163
|
}
|
|
167
164
|
```
|
|
@@ -223,16 +220,16 @@ formatNumber({ country: 'US', phone: '2133734253' }, 'NATIONAL')
|
|
|
223
220
|
|
|
224
221
|
### "As You Type" formatter
|
|
225
222
|
|
|
226
|
-
Parses and formats
|
|
223
|
+
Parses and formats a complete or incomplete phone number.
|
|
227
224
|
|
|
228
225
|
```js
|
|
229
226
|
import { AsYouType } from 'libphonenumber-js'
|
|
230
227
|
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
// Country not specified — use international format
|
|
229
|
+
new AsYouType().input('+12133734') === '+1 213 373 4'
|
|
233
230
|
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
// Country specified — use national format
|
|
232
|
+
new AsYouType('US').input('2133734') === '(213) 373-4'
|
|
236
233
|
```
|
|
237
234
|
|
|
238
235
|
### Validate phone number
|
|
@@ -249,8 +246,8 @@ import {
|
|
|
249
246
|
isPossiblePhoneNumber('8 (800) 555-35-35', 'RU') === true
|
|
250
247
|
isValidPhoneNumber('8 (800) 555-35-35', 'RU') === true
|
|
251
248
|
|
|
252
|
-
validatePhoneNumberLength('8 (800) 555', 'RU') === 'TOO_SHORT'
|
|
253
|
-
validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined // Length is valid
|
|
249
|
+
validatePhoneNumberLength('8 (800) 555', 'RU') === 'TOO_SHORT' // Length is invalid
|
|
250
|
+
validatePhoneNumberLength('8 (800) 555-35-35', 'RU') === undefined // Length is valid
|
|
254
251
|
```
|
|
255
252
|
|
|
256
253
|
`isPossiblePhoneNumber()` only validates phone number length, while `isValidPhoneNumber()` validates both phone number length and phone number digits.
|
|
@@ -271,37 +268,37 @@ import { findPhoneNumbersInText } from 'libphonenumber-js'
|
|
|
271
268
|
findPhoneNumbersInText(`
|
|
272
269
|
For tech support call +7 (800) 555-35-35 internationally
|
|
273
270
|
or reach a local US branch at (213) 373-4253 ext. 1234.
|
|
274
|
-
`, 'US')
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
271
|
+
`, 'US') ===
|
|
272
|
+
[
|
|
273
|
+
{
|
|
274
|
+
number: PhoneNumber {
|
|
275
|
+
country: 'RU',
|
|
276
|
+
countryCallingCode: '7',
|
|
277
|
+
number: '+78005553535',
|
|
278
|
+
nationalNumber: '8005553535'
|
|
279
|
+
},
|
|
280
|
+
startsAt: 22,
|
|
281
|
+
endsAt: 40
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
number: PhoneNumber {
|
|
285
|
+
country: 'US',
|
|
286
|
+
countryCallingCode: '1',
|
|
287
|
+
number: '+12133734253',
|
|
288
|
+
nationalNumber: '2133734253',
|
|
289
|
+
ext: '1234'
|
|
290
|
+
},
|
|
291
|
+
startsAt: 86,
|
|
292
|
+
endsAt: 110
|
|
293
|
+
}
|
|
294
|
+
]
|
|
298
295
|
```
|
|
299
296
|
|
|
300
297
|
## "min" vs "max" vs "mobile" vs "core"
|
|
301
298
|
|
|
302
|
-
This
|
|
299
|
+
This package lets a developer choose from different "metadata" sets, where a "metadata" set is a complete list of phone number parsing and formatting rules for all possible countries.
|
|
303
300
|
|
|
304
|
-
As one may guess, the complete list of those rules is huge, so this
|
|
301
|
+
As one may guess, the complete list of those rules is huge, so this package provides a way to optimize the bundle size by choosing between `max`, `min`, `mobile` or "custom" metadata, depending on the project's needs.
|
|
305
302
|
|
|
306
303
|
* `min` — (default) The smallest metadata set
|
|
307
304
|
* Is about `80 kilobytes` in size (`libphonenumber-js/metadata.min.json` file)
|
|
@@ -346,11 +343,13 @@ As for "custom" metadata, it could be used in those rare cases when not all coun
|
|
|
346
343
|
|
|
347
344
|
## Definitions
|
|
348
345
|
|
|
346
|
+
This package introduces a few new terms in order describe its behavior more precisely.
|
|
347
|
+
|
|
349
348
|
### National (Significant) Number
|
|
350
349
|
|
|
351
|
-
"National (significant) number" is all national phone number digits
|
|
350
|
+
"National (significant) number" is all national phone number digits excluding the "national prefix". Examples:
|
|
352
351
|
* International number: `+1 213 373 4253`. Country: `"US"`. National number: `(213) 373-4253`. National (significant) number: `213 373 4253`
|
|
353
|
-
* Inetrnational number: `+33 1 45 45 32 45`. Country: `"FR"`. National number: `01 45 45 32 45`. Notice the `0` at the start of the national number — it's because in France they [add](https://en.wikipedia.org/wiki/Telephone_numbers_in_France)
|
|
352
|
+
* Inetrnational number: `+33 1 45 45 32 45`. Country: `"FR"`. National number: `01 45 45 32 45`. Notice the `0` at the start of the national number — it's because in France they [add](https://en.wikipedia.org/wiki/Telephone_numbers_in_France) it when writing phone numbers in national format. National (significant) number: `1 45 45 32 45` (doesn't include the "national prefix")
|
|
354
353
|
|
|
355
354
|
### Country Calling Code
|
|
356
355
|
|
|
@@ -362,7 +361,12 @@ In some cases, multiple countries could share the same "country calling code". F
|
|
|
362
361
|
|
|
363
362
|
### Non-Geographic
|
|
364
363
|
|
|
365
|
-
|
|
364
|
+
Some "country calling codes" don't belong to any given country or territory and are by-design international. Such phone numbers are called "non-geographic", and their `country` property is `undefined`.
|
|
365
|
+
|
|
366
|
+
<details>
|
|
367
|
+
<summary>Here's a full list of "non-geographic" calling codes.</summary>
|
|
368
|
+
|
|
369
|
+
######
|
|
366
370
|
|
|
367
371
|
* `+800` — [Universal International Toll Free Number](https://en.wikipedia.org/wiki/Toll-free_telephone_number)
|
|
368
372
|
* `+808` — [Universal International Shared Cost Number](https://en.wikipedia.org/wiki/Shared-cost_service)
|
|
@@ -372,8 +376,7 @@ The following "calling codes" don't belong to any given country or territory and
|
|
|
372
376
|
* `+882` and `+883` — [International Networks](https://en.wikipedia.org/wiki/International_Networks_(country_code))
|
|
373
377
|
* `+888` — [United Nations Office for the Coordination of Humanitarian Affairs](https://en.wikipedia.org/wiki/United_Nations_Office_for_the_Coordination_of_Humanitarian_Affairs#International_Dialing_Code)
|
|
374
378
|
* `+979` — [International Premium Rate Service](https://en.wikipedia.org/wiki/International_Premium_Rate_Service)
|
|
375
|
-
|
|
376
|
-
Such phone numbers are called "non-geographic", and their `country` is `undefined`.
|
|
379
|
+
</details>
|
|
377
380
|
|
|
378
381
|
### Country Code
|
|
379
382
|
|
|
@@ -383,7 +386,7 @@ However, this library uses the term "country code" rather broadly and it include
|
|
|
383
386
|
|
|
384
387
|
For that reason, a developer should use a "country code" returned from this library with caution in an application that only expects the official ISO "country codes" to exist. For example, such application will likely not have a label or a flag for such an unofficial "country code".
|
|
385
388
|
|
|
386
|
-
A developer could manually transform any unofficial "country code" returned from this library to a most-suitable official one.
|
|
389
|
+
A developer could manually transform any unofficial "country code" returned from this library to a most-suitable official one. Because there's no obvious answer in such case, it's up to developers themselves to decide which country name or flag to show.
|
|
387
390
|
|
|
388
391
|
To get a list of all supported "country codes", both official and unofficial, use [`getCountries()`](#getcountries-string) function.
|
|
389
392
|
|
|
@@ -391,7 +394,17 @@ To check if a certain two-letter "country code" is supported by this library, us
|
|
|
391
394
|
|
|
392
395
|
### Country Code (additions)
|
|
393
396
|
|
|
394
|
-
Here's a list of the unofficial "country codes"
|
|
397
|
+
Here's a list of the unofficial "country codes". These codes are used for certain "regions" that're usually a subject of a [territorial dispute](https://en.wikipedia.org/wiki/Territorial_dispute).
|
|
398
|
+
|
|
399
|
+
* `AC` — [Ascension Island](https://en.wikipedia.org/wiki/Ascension_Island)
|
|
400
|
+
* `TA` — [Tristan da Cunha](https://en.wikipedia.org/wiki/Tristan_da_Cunha)
|
|
401
|
+
* `SH` — [Saint Helena](https://en.wikipedia.org/wiki/Saint_Helena)
|
|
402
|
+
* `XK` — [Kosovo](https://en.wikipedia.org/wiki/Kosovo)
|
|
403
|
+
|
|
404
|
+
<details>
|
|
405
|
+
<summary>Here're some more details on each one of them for those who're interested.</summary>
|
|
406
|
+
|
|
407
|
+
######
|
|
395
408
|
|
|
396
409
|
* `AC` — [Ascension Island](https://en.wikipedia.org/wiki/Ascension_Island)
|
|
397
410
|
* (history) The region of Ascension Island is officially part of [Saint Helena, Ascension and Tristan da Cunha
|
|
@@ -418,25 +431,42 @@ Here's a list of the unofficial "country codes" — these codes are used for cer
|
|
|
418
431
|
* An unofficial code `XK` is used for Kosovo region in Google's `libphonenumber`.
|
|
419
432
|
* `XK` is a ["user-assigned"](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#User-assigned_code_elements) code in the ISO-3166-1 standard meaning that it can be freely assigned to any region by any application or organization for its own purposes.
|
|
420
433
|
* The last official ISO-3166-2 ["subdivision code"](https://en.wikipedia.org/wiki/ISO_3166-2) assigned to Kosovo region [is](https://en.wikipedia.org/wiki/Autonomous_Province_of_Kosovo_and_Metohija) `RS-KM`.
|
|
434
|
+
</details>
|
|
435
|
+
|
|
436
|
+
######
|
|
437
|
+
|
|
438
|
+
There's also a list of territories that have a disputed status of an independent state. For obvious reasons, they dropped the use of their original parent territory's telephone numbering plan and instead joined another state's telephone numbering plan.
|
|
421
439
|
|
|
422
|
-
|
|
423
|
-
|
|
440
|
+
* [Abkhazia](https://en.wikipedia.org/wiki/Abkhazia) — used to be part of [Georgia](https://en.wikipedia.org/wiki/Georgia_(country)) (`GE`) but currently uses the telephone numbering plan of [Russia](https://en.wikipedia.org/wiki/Russia) (`RU`)
|
|
441
|
+
* [South Ossetia](https://en.wikipedia.org/wiki/South_Ossetia) — used to be part of [Georgia](https://en.wikipedia.org/wiki/Georgia_(country)) (`GE`) but currently uses the telephone numbering plan of [Russia](https://en.wikipedia.org/wiki/Russia) (`RU`)
|
|
442
|
+
* [Northern Cyprus](https://en.wikipedia.org/wiki/Northern_Cyprus) — used to be part of [Cyprus](https://en.wikipedia.org/wiki/Cyprus) (`CY`) but currently uses the telephone numbering plan of [Turkey](https://en.wikipedia.org/wiki/Turkey) (`TR`)
|
|
443
|
+
|
|
444
|
+
<details>
|
|
445
|
+
<summary>Here're some more details on each one of them for those who're interested.</summary>
|
|
446
|
+
|
|
447
|
+
######
|
|
448
|
+
|
|
449
|
+
These territories are currently not implemented in this library but they could potentially be implemented in some future:
|
|
450
|
+
* [Abkhazia](https://en.wikipedia.org/wiki/Abkhazia)
|
|
424
451
|
* (history) The region of Abkhazia separated from [Georgia](https://en.wikipedia.org/wiki/Georgia_(country)) (`GE`) during a civil war in 1992-1994. The government of Abkhazia officially (unilaterally) declared independence from Georgia in 1994 when the civil war was put to an end. The first state to officially recognize Abkhazia's independence was Russia in 2008.
|
|
425
452
|
* Abkhazia currently shares a country calling code of `+7` with [Russia](https://en.wikipedia.org/wiki/Russia) (`RU`) where it has [unique prefixes](https://en.wikipedia.org/wiki/Telephone_numbers_in_Russia#Codes_assigned_to_Abkhazia) of `840` and `940`, so the "country code" is currently parsed as `RU`.
|
|
426
453
|
* For the purpose of differentiating Abkhazia phone numbers from Russia phone numbers, an unofficial code like `XA` could be used for it in Google's `libphonenumber`.
|
|
427
454
|
* `XA` is a ["user-assigned"](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#User-assigned_code_elements) code in the ISO-3166-1 standard meaning that it can be freely assigned to any region by any application or organization for its own purposes.
|
|
428
455
|
* The last official ISO-3166-2 ["subdivision code"](https://en.wikipedia.org/wiki/ISO_3166-2) assigned to Abkhazia region [is](https://en.wikipedia.org/wiki/ISO_3166-2:GE) `GE-AB`.
|
|
429
|
-
|
|
456
|
+
|
|
457
|
+
* [South Ossetia](https://en.wikipedia.org/wiki/South_Ossetia)
|
|
430
458
|
* (history) The region of South Ossetia separated from [Georgia](https://en.wikipedia.org/wiki/Georgia_(country)) (`GE`) during a civil war 1991–1992. The government of South Ossetia officially (unilaterally) declared independence from Georgia in 1992 when the civil war was put to an end. The first state to officially recognize South Ossetia's independence was Russia in 2008.
|
|
431
459
|
* South Ossetia currently shares a country calling code of `+7` with [Russia](https://en.wikipedia.org/wiki/Russia) (`RU`) where it has [unique prefixes](https://en.wikipedia.org/wiki/Telephone_numbers_in_Russia#Codes_assigned_to_South_Ossetia) of `850` and `929`, so the "country code" is currently parsed as `RU`.
|
|
432
460
|
* For the purpose of differentiating South Ossetia phone numbers from Russia phone numbers, an unofficial code like `XO` could be used for it in Google's `libphonenumber`.
|
|
433
461
|
* `XO` is a ["user-assigned"](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#User-assigned_code_elements) code in the ISO-3166-1 standard meaning that it can be freely assigned to any region by any application or organization for its own purposes.
|
|
434
462
|
* South Ossetia region has [not](https://en.wikipedia.org/wiki/ISO_3166-2:GE) ever been assigned any official ISO-3166-2 ["subdivision code"](https://en.wikipedia.org/wiki/ISO_3166-2).
|
|
435
|
-
|
|
463
|
+
|
|
464
|
+
* [Northern Cyprus](https://en.wikipedia.org/wiki/Northern_Cyprus)
|
|
436
465
|
* (history) The region of Northern Cyprus separated from [Cyprus](https://en.wikipedia.org/wiki/Cyprus) (`CY`) during [Turkey](https://en.wikipedia.org/wiki/Turkey)'s military invasion in 1974. The government of Northern Cyprus officially (unilaterally) declared independence from Cyprus in 1983. The first state to officially recognize Northern Cyprus' independence was Turkey in 1983.
|
|
437
466
|
* Northern Cyprus currently shares a country calling code of `+90` with Turkey (`TR`) where it has [unique prefixes](https://en.wikipedia.org/wiki/Telephone_numbers_in_Northern_Cyprus) of `392`, `533` and `542`, so the "country code" is currently parsed as `TR`.
|
|
438
467
|
* For the purpose of differentiating Northern Cyprus phone numbers from Turkey phone numbers, some unofficial code like `XC` could be used for it in Google's `libphonenumber`.
|
|
439
468
|
* Northern Cyprus region has [not](https://en.wikipedia.org/wiki/ISO_3166-2:CY) ever been assigned any official ISO-3166-2 ["subdivision code"](https://en.wikipedia.org/wiki/ISO_3166-2).
|
|
469
|
+
</details>
|
|
440
470
|
|
|
441
471
|
## API
|
|
442
472
|
|