Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 519 lines (443 sloc) 18.671 kb
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
1 # All countries, ordered by country code.
2 #
3 # Definitions are in the format:
4 # NDC >> National | NDC >> National | # ...
5 #
6 # As soon as a NDC matches, it goes on to the National part. Then breaks off.
7 # If the NDC does not match, it go on to the next (|, or "or") NDC.
8 #
9 # Available matching/splitting methods:
10 # * none: Does not have a national destination code, e.g. Denmark, Iceland.
11 # * one_of: Matches one of the following numbers. Splits if it does.
12 # * match: Try to match the regex, and if it matches, splits it off.
13 # * fixed: Always splits off a fixed length ndc. (Always use last in a | chain)
14 #
15 # For the national number part, there are two:
16 # * split: Use this number group splitting.
17 # * matched_split: Give a hash of regex => format array, with a :fallback => format option.
18 # (See Norway how it looks.)
19 #
20 # Note: The ones that are commented are defined in their special files.
21 #
22 Phony.define do
8e926b0 @floere - belgium special file
authored
23
24 # Reserved.
25 #
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
26 country '0', fixed(1) >> split(10) # Reserved.
27
8e926b0 @floere - belgium special file
authored
28 # USA, Canada, etc.
29 #
30 country '1', fixed(3) >> split(3,4)
31
32 # Kazakhstan (Republic of) & Russian Federation.
33 #
34 country '7', fixed(3) >> split(3,2,2)
35
36 # Egypt.
37 #
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
38 country '20', one_of('800') >> split(7) | # Egypt
39 one_of('2', '3') >> split(8) | # Cairo/Giza, Alexandria
40 fixed(2) >> split(8)
41 # :mobile? => /^10|11|12|14|16|17|18|19*$/, :service? => /^800.*$/
8e926b0 @floere - belgium special file
authored
42
43 # South Africa.
44 #
45 country '27', fixed(2) >> split(3,4)
46
6f14f18 @floere - greece special file
authored
47 # Greece.
48 #
49 country '30', match(/^(2[3-8]?1|69[0345789]|800)\d+$/) >> split(6) | # Geo/Mobile
50 fixed(4) >> split(6) # 3-digit NDCs
51
8e926b0 @floere - belgium special file
authored
52 # country '31' # Netherlands, see special file.
53
54 # Belgium.
55 #
56 country '32', match(/^(70|800|90\d)\d+$/) >> split(3,3) | # Service
57 match(/^(4[789]\d)\d{6}$/) >> split(6) | # Mobile
58 one_of('2','3','4','9') >> split(3,5) | # Short NDCs
59 fixed(2) >> split(3,5) # 2-digit NDCs
60
61 # France.
62 #
63 country '33', fixed(1) >> split(2,2,2,2) # :service? => /^8.*$/, :mobile? => /^[67].*$/
64
65 # Spain.
66 #
67 country '34', fixed(2) >> split(3,4)
68
96bb9bb @floere + Moved Hungary to main file
authored
69 # Hungary.
70 #
71 # TODO Mobile.
72 #
73 country '36', one_of('104','105','107','112') >> split(3,3) | # Service
74 one_of('1') >> split(3,4) | # Budapest
75 fixed(2) >> split(3,4) # 2-digit NDCs
76
8e926b0 @floere - belgium special file
authored
77 # country '39' # Italy, see special file.
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
78
cf11e22 @floere - Romanian special file
authored
79 # Romania.
80 #
81 country '40', match(/^(112|800|90[036])\d+$/) >> split(3,3) | # Service
82 match(/^(7[1-8])\d+$/) >> split(3,4) | # Mobile
83 one_of('21', '31') >> split(3,4) | # Bucureşti
84 fixed(3) >> split(3,4) # 3-digit NDCs
ff7e0dc @floere + countries.rb cleanup and explanations
authored
85
86 # Switzerland.
87 #
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
88 # :service => %w{800 840 842 844 848}, :mobile => %w{74 76 77 78 79}
89 swiss_service_regex = /^(800|840|842|844|848)\d+$/
ff7e0dc @floere + countries.rb cleanup and explanations
authored
90 country '41', match(swiss_service_regex) >> split(3,3) |
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
91 fixed(2) >> split(3,2,2)
ff7e0dc @floere + countries.rb cleanup and explanations
authored
92
93
94 # country '43' # Austria, see special file.
95 # country '44' # UnitedKingdom, see special file.
96
97 # Denmark.
98 #
99 country '45', none >> split(2,2,2,2)
100
101 # country '46' # Sweden, see special file.
102
103 # Norway.
104 #
105 country '47', none >> matched_split(/^[1].*$/ => [3], /^[489].*$/ => [3,2,3], :fallback => [2,2,2,2])
106
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
107 # Poland (Republic of)
108 # Although the NDCs are 2 digits, the representation is 3 digits.
109 # Note: http://wapedia.mobi/en/Telephone_numbers_in_Poland, mobile not yet correct
110 #
111 country '48', fixed(3) >> split(3,3) # Poland
112
ff7e0dc @floere + countries.rb cleanup and explanations
authored
113 # country '49' # Germany, see special file.
114
115 # Peru.
116 #
117 country '51', one_of('103', '105') >> split(3,3) | # Service.
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
118 one_of('1', '9') >> split(4,4) | # Lima and mobile.
ff7e0dc @floere + countries.rb cleanup and explanations
authored
119 fixed(2) >> split(4,4) # 2-digit NDCs.
120
121 # Mexico.
122 #
123 country '52', match(/^(0\d{2})\d+$/) >> split(2,2,2,2) |
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
124 match(/^(33|55|81)\d+$/) >> split(2,2,2,2) |
125 match(/^(\d{3})\d+$/) >> split(3,2,2)
ff7e0dc @floere + countries.rb cleanup and explanations
authored
126
127 # Cuba.
128 #
129 country '53', match(/^(5\d{3})\d+$/) >> split(4) | # Mobile
130 match(/^(7|21|22|23|4[1-8]|3[1-3])/) >> split(7) | # Short NDCs
131 fixed(3) >> split(7) # 3-digit NDCs
132
133 # TODO Argentine Republic.
134 #
135 country '54', fixed(2) >> split(3,2,2)
136
137 # Brazil (Federative Republic of).
138 #
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
139 brazilian_service = /^(100|128|190|191|192|193|194|197|198|199)\d+$/
ff7e0dc @floere + countries.rb cleanup and explanations
authored
140 country '55', match(brazilian_service) >> split(3,3) | # Service.
141 fixed(2) >> split(4,4) # NDCs
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
142 # :service? => brazilian_service, :mobile? => ?
143 # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
144
9e4da68 @floere + Moved Chile to main file, - Chile special file, + Spec
authored
145 # Chile.
146 #
147 country '56', match(/^(13[0-79]|14[79])\d+$/) >> split(3,3) | # Service
148 one_of('2', '9') >> split(8) | # Santiago, Mobile
149 fixed(2) >> split(8) # 2-digit NDCs
ff7e0dc @floere + countries.rb cleanup and explanations
authored
150
151 # TODO Colombia.
152 #
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
153 country '57', default
ff7e0dc @floere + countries.rb cleanup and explanations
authored
154
155 # Venezuela (Bolivarian Republic of)
156 #
157 country '58', fixed(3) >> split(7)
158
159 # country '60' # Malaysia, see special file.
160
161 # Australia.
162 #
163 country '61', match(/^(4\d\d)\d+$/) >> split(3,3) | # Mobile
164 fixed(1) >> split(4,4) # Rest
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
165 country '62', default # TODO Indonesia (Republic of)
166 country '63', default # TODO Philippines (Republic of the)
ff7e0dc @floere + countries.rb cleanup and explanations
authored
167
168 # New Zealand.
169 #
170 # TODO Mobile?
171 #
172 country '64', fixed(1) >> split(3,4)
173
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
174 country '65', default # TODO Singapore (Republic of)
175 country '66', default # TODO Thailand
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
176
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
177 country '81', default # TODO Japan
ff7e0dc @floere + countries.rb cleanup and explanations
authored
178
179 # country '82' # SouthKorea, see special file.
180
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
181 country '84', default # TODO Viet Nam (Socialist Republic of)
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
182
ff7e0dc @floere + countries.rb cleanup and explanations
authored
183 # country '86' # China, see special file.
184
185 # Turkey.
186 #
187 country '90', fixed(3) >> split(3,4) # Wiki says 7, but the examples say 3, 4.
188
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
189 country '91', default # TODO India (Republic of)
190 country '92', default # TODO Pakistan (Islamic Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_Pakistan, NDC 2-5
ff7e0dc @floere + countries.rb cleanup and explanations
authored
191
192 # Afghanistan.
193 #
194 # From http://www.wtng.info/wtng-93-af.html
195 #
196 country '93', fixed(2) >> split(7) # Note: the document says 6, but the examples use 7.
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
197
198 country '94', fixed(2) >> split(3,2,2) # TODO Sri Lanka (Democratic Socialist Republic of)
199 country '95', fixed(2) >> split(3,2,2) # TODO Myanmar (Union of)
200 country '98', fixed(2) >> split(3,2,2) # TODO Iran (Islamic Republic of)
201
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
202 country '210', default # -
203 country '211', default # -
204 country '212', default # Morocco
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
205 country '213', fixed(2) >> split(3,4) # Algeria
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
206 country '214', default # -
207 country '215', default # -
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
208 country '216', fixed(1) >> split(3,4) # Tunisia
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
209 country '217', default # -
210 country '218', default # Lybia
211 country '219', default # -
212
213 country '220', default # Gambia
214 country '221', default # Senegal
215 country '222', default # Mauritania
216 country '223', default # Mali
217 country '224', default # Guinea
218 country '225', default # Côte d'Ivoire
219 country '226', default # Burkina Faso
220 country '227', default # Niger
221 country '228', default # Togolese Republic
222 country '229', default # Benin
223
224 country '230', default # Mauritius
225 country '231', default # Liberia
226 country '232', default # Sierra Leone
227 country '233', default # Ghana
228 country '234', default # Nigeria
229 country '235', default # Chad
230 country '236', default # Central African Republic
231 country '237', default # Cameroon
232 country '238', default # Cape Verde
233 country '239', default # Sao Tome and Principe
234
235 country '240', default # Equatorial Guinea
236 country '241', default # Gabonese Republic
237 country '242', default # Congo
238 country '243', default # Democratic Republic of the Congo
239 country '244', default # Angola
240 country '245', default # Guinea-Bissau
241 country '246', default # Diego Garcia
242 country '247', default # Ascension
243 country '248', default # Seychelles
244 country '249', default # Sudan
245
246 country '250', default # Rwanda
247 country '251', default # Ethiopia
248 country '252', default # Somali Democratic Republic
249 country '253', default # Djibouti
250 country '254', default # Kenya
251 country '255', default # Tanzania
252 country '256', default # Uganda
253 country '257', default # Burundi
254 country '258', default # Mozambique
255 country '259', default # -
256
257 country '260', default # Zambia
258 country '261', default # Madagascar
259 country '262', default # Reunion / Mayotte (new)
260 country '263', default # Zimbabwe
261 country '264', default # Namibia
262 country '265', default # Malawi
263 country '266', default # Lesotho
264 country '267', default # Botswana
265 country '268', default # Swaziland
266 country '269', default # Comoros
267
268 country '280', default # -
269 country '281', default # -
270 country '282', default # -
271 country '283', default # -
272 country '284', default # -
273 country '285', default # -
274 country '286', default # -
275 country '287', default # -
276 country '288', default # -
277 country '289', default # -
278 country '290', default # Saint Helena
279
280 country '291', default # Eritrea
281 country '292', default # -
282 country '293', default # -
283 country '294', default # -
284 country '295', default # -
285 country '296', default # -
286 country '297', default # Aruba
287 country '298', default # Faroe Islands
288 country '299', default # Greenland
289
290 country '350', default # Gibraltar
ff7e0dc @floere + countries.rb cleanup and explanations
authored
291
292 # Portugal.
293 #
294 country '351', one_of('700', '800') >> split(3,3) | # Service.
295 match(/^(9\d)\d+$/) >> split(3,4) | # Mobile.
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
296 one_of('21', '22') >> split(3,4) | # Lisboa & Porto
ff7e0dc @floere + countries.rb cleanup and explanations
authored
297 fixed(3) >> split(3,4) # 3-digit NDCs
298
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
299 country '352', default # Luxembourg
300 country '353', default # Ireland (0-3-4)
301 country '354', none >> split(3,4) # Iceland
302 country '355', default # Albania
303 country '356', default # Malta
304 country '357', default # Cyprus
ff7e0dc @floere + countries.rb cleanup and explanations
authored
305
306 # Finland.
307 #
308 country '358', match(/^([6-8]00)\d+$/) >> split(3,3) | # Service
309 match(/^(4\d|50)\d+$/) >> split(3,2,2) | # Mobile
310 one_of('2','3','5','6','8','9') >> split(3,3) | # Short NDCs
311 fixed(2) >> split(3,3) # 2-digit NDCs
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
312 country '359', fixed(2) >> split(3,2,2) # Bulgaria
313
ff7e0dc @floere + countries.rb cleanup and explanations
authored
314 # Lithuania.
315 #
316 country '370', one_of('700', '800') >> split(2,3) | # Service
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
317 match(/^(6\d\d)\d+$/) >> split(2,3) | # Mobile
318 one_of('5') >> split(3,2,2) | # Vilnius
ff7e0dc @floere + countries.rb cleanup and explanations
authored
319 one_of('37','41') >> split(2,2,2) | # Kaunas, Šiauliai
320 fixed(3) >> split(1,2,2) # 3-digit NDCs.
321
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
322 country '371', default # Latvia
323 country '372', default # Estonia
324 country '373', default # Moldova
325 country '374', default # Armenia
326 country '375', default # Belarus
327 country '376', default # Andorra
328 country '377', default # Monaco
329 country '378', default # San Marino
330 country '379', default # Vatican City State
331
332 country '380', default # Ukraine
333 country '381', default # Serbia and Montenegro
334 country '382', default # -
335 country '383', default # -
336 country '384', default # -
ff7e0dc @floere + countries.rb cleanup and explanations
authored
337
338 # Croatia.
339 #
340 country '385', one_of('1') >> split(3,5) | # Zagreb
341 fixed(2) >> split(3,5) # 2-digit NDCs
342
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
343 country '386', fixed(2) >> split(3,2,2) # Slovenia
344 country '387', fixed(2) >> split(3,2,2) # Bosnia and Herzegovina
345 country '388', fixed(2) >> split(3,2,2) # Group of countries, shared code
346 country '389', fixed(2) >> split(3,2,2) # The Former Yugoslav Republic of Macedonia
347
348 country '420', fixed(3) >> split(3,3) # Czech Republic
ff7e0dc @floere + countries.rb cleanup and explanations
authored
349
350 # Slovak Republic.
351 #
352 country '421', match(/^(9\d\d).+$/) >> split(6) | # Mobile
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
353 one_of('2') >> split(8) | # Bratislava
ff7e0dc @floere + countries.rb cleanup and explanations
authored
354 fixed(2) >> split(7) # 2-digit NDCs
355
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
356 country '422', default # Spare code
357 country '423', none >> split(3,2,2) # Liechtenstein (Principality of)
358 country '424', default # -
359 country '425', default # -
360 country '426', default # -
361 country '427', default # -
362 country '428', default # -
363 country '429', default # -
364
365 country '500', default # Falkland Islands (Malvinas)
366 country '501', default # Belize
367 country '502', default # Guatemala (Republic of)
368 country '503', default # El Salvador (Republic of)
369 country '504', default # Honduras (Republic of)
370 country '505', default # Nicaragua
371 country '506', default # Costa Rica
372 country '507', default # Panama (Republic of)
373 country '508', default # Saint Pierre and Miquelon (Collectivité territoriale de la République française)
374 country '509', default # Haiti (Republic of)
375
376 country '590', default # Guadeloupe (French Department of)
377 country '591', default # Bolivia (Republic of)
378 country '592', default # Guyana
379 country '593', default # Ecuador
380 country '594', default # French Guiana (French Department of)
381 country '595', default # Paraguay (Republic of)
382 country '596', default # Martinique (French Department of)
383 country '597', default # Suriname (Republic of)
384 country '598', default # Uruguay (Eastern Republic of)
385 country '599', default # Netherlands Antilles
386
387 country '670', default # Democratic Republic of Timor-Leste
388 country '671', default # Spare code
389 country '672', default # Australian External Territories
390 country '673', default # Brunei Darussalam
391 country '674', default # Nauru (Republic of)
392 country '675', default # Papua New Guinea
393 country '676', default # Tonga (Kingdom of)
394 country '677', default # Solomon Islands
395 country '678', default # Vanuatu (Republic of)
396 country '679', default # Fiji (Republic of)
397
398 country '680', default # Palau (Republic of)
399 country '681', default # Wallis and Futuna (Territoire français d'outre-mer)
400 country '682', default # Cook Islands
401 country '683', default # Niue
402 country '684', default # -
403 country '685', default # Samoa (Independent State of)
404 country '686', default # Kiribati (Republic of)
405 country '687', default # New Caledonia (Territoire français d'outre-mer)
406 country '688', default # Tuvalu
407 country '689', default # French Polynesia (Territoire français d'outre-mer)
408
409 country '690', default # Tokelau
410 country '691', default # Micronesia (Federated States of)
411 country '692', default # Marshall Islands (Republic of the)
412 country '693', default # -
413 country '694', default # -
414 country '695', default # -
415 country '696', default # -
416 country '697', default # -
417 country '698', default # -
418 country '699', default # -
419
420 country '800', default # International Freephone Service
421 country '801', default # -
422 country '802', default # -
423 country '803', default # -
424 country '804', default # -
425 country '805', default # -
426 country '806', default # -
427 country '807', default # -
428 country '808', default # International Shared Cost Service (ISCS)
429 country '809', default # -
430
431 country '830', default # -
432 country '831', default # -
433 country '832', default # -
434 country '833', default # -
435 country '834', default # -
436 country '835', default # -
437 country '836', default # -
438 country '837', default # -
439 country '838', default # -
440 country '839', default # -
441
442 country '850', default # Democratic People's Republic of Korea
443 country '851', default # Spare code
444 country '852', default # Hong Kong, China
445 country '853', default # Macao, China
446 country '854', default # Spare code
447 country '855', default # Cambodia (Kingdom of)
448 country '856', default # Lao People's Democratic Republic
449 country '857', default # Spare code
450 country '858', default # Spare code
451 country '859', default # Spare code
452
453 country '870', default # Inmarsat SNAC
454 country '871', default # Inmarsat (Atlantic Ocean-East)
455 country '872', default # Inmarsat (Pacific Ocean)
456 country '873', default # Inmarsat (Indian Ocean)
457 country '874', default # Inmarsat (Atlantic Ocean-West)
458 country '875', default # Reserved - Maritime Mobile Service Applications
459 country '876', default # Reserved - Maritime Mobile Service Applications
460 country '877', default # Reserved - Maritime Mobile Service Applications
461 country '878', default # Universal Personal Telecommunication Service (UPT)
462 country '879', default # Reserved for national non-commercial purposes
b6cbfbb @floere + moved countries.rb inside phony (thanks trans!)
authored
463
3851473 @mrchucho Allow unsupported countries to use a more conservative default.
mrchucho authored
464 country '880', default # Bangladesh (People's Republic of)
e4bacb0 @floere + use default DSL method on all countries that are TODO
authored
465 country '881', default # International Mobile, shared code
466 country '882', default # International Networks, shared code
467 country '883', default # -
468 country '884', default # -
469 country '885', default # -
470 country '886', default # Reserved
471 country '887', default # -
472 country '888', default # Reserved for future global service
473 country '889', default # -
474
475 country '890', default # -
476 country '891', default # -
477 country '892', default # -
478 country '893', default # -
479 country '894', default # -
480 country '895', default # -
481 country '896', default # -
482 country '897', default # -
483 country '898', default # -
484 country '899', default # -
485
486 country '960', default # Maldives (Republic of)
487 country '961', default # Lebanon
488 country '962', default # Jordan (Hashemite Kingdom of)
489 country '963', default # Syrian Arab Republic
490 country '964', default # Iraq (Republic of)
491 country '965', default # Kuwait (State of)
492 country '966', default # Saudi Arabia (Kingdom of)
493 country '967', default # Yemen (Republic of)
494 country '968', default # Oman (Sultanate of)
495 country '969', default # Reserved - reservation currently under investigation
496
497 country '970', default # Reserved
498 country '971', default # United Arab Emirates
499 country '972', default # Israel (State of)
500 country '973', default # Bahrain (Kingdom of)
501 country '974', default # Qatar (State of)
502 country '975', default # Bhutan (Kingdom of)
503 country '976', default # Mongolia
504 country '977', default # Nepal
505 country '978', default # -
506 country '979', default # International Premium Rate Service (IPRS)
507
508 country '990', default # Spare code
509 country '991', default # Trial of a proposed new international telecommunication public correspondence service, shared code
510 country '992', default # Tajikistan (Republic of)
511 country '993', default # Turkmenistan
512 country '994', default # Azerbaijani Republic
513 country '995', default # Georgia
514 country '996', default # Kyrgyz Republic
515 country '997', default # Spare code
516 country '998', default # Uzbekistan (Republic of)
517 country '999', default # Reserved for possible future use within the Telecommunications for Disaster Relief (TDR) concept
3851473 @mrchucho Allow unsupported countries to use a more conservative default.
mrchucho authored
518 end
Something went wrong with that request. Please try again.