46

在这个Wikipedia 条目中,我发现 ITU 电信标准化部门 (ITU-T) 正在提供此类国家呼叫代码列表。

这是一个pdf:http ://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.164D-2009-PDF-E.pdf

我想知道在 xml 文件或类似文件中哪里可以找到它?我需要在 javascript 和 c# 中找出电话号码来自哪个国家/地区。

4

10 回答 10

103

我生成了以下格式的 json 文件(希望对您有所帮助):

{
  "countries": [
    {
      "code": "+7 840",
      "name": "Abkhazia"
    },
    {
      "code": "+93",
      "name": "Afghanistan"
    },
    {
      "code": "+355",
      "name": "Albania"
    },
    {
      "code": "+213",
      "name": "Algeria"
    },
    {
      "code": "+1 684",
      "name": "American Samoa"
    },
    {
      "code": "+376",
      "name": "Andorra"
    },
    {
      "code": "+244",
      "name": "Angola"
    },
    {
      "code": "+1 264",
      "name": "Anguilla"
    },
    {
      "code": "+1 268",
      "name": "Antigua and Barbuda"
    },
    {
      "code": "+54",
      "name": "Argentina"
    },
    {
      "code": "+374",
      "name": "Armenia"
    },
    {
      "code": "+297",
      "name": "Aruba"
    },
    {
      "code": "+247",
      "name": "Ascension"
    },
    {
      "code": "+61",
      "name": "Australia"
    },
    {
      "code": "+672",
      "name": "Australian External Territories"
    },
    {
      "code": "+43",
      "name": "Austria"
    },
    {
      "code": "+994",
      "name": "Azerbaijan"
    },
    {
      "code": "+1 242",
      "name": "Bahamas"
    },
    {
      "code": "+973",
      "name": "Bahrain"
    },
    {
      "code": "+880",
      "name": "Bangladesh"
    },
    {
      "code": "+1 246",
      "name": "Barbados"
    },
    {
      "code": "+1 268",
      "name": "Barbuda"
    },
    {
      "code": "+375",
      "name": "Belarus"
    },
    {
      "code": "+32",
      "name": "Belgium"
    },
    {
      "code": "+501",
      "name": "Belize"
    },
    {
      "code": "+229",
      "name": "Benin"
    },
    {
      "code": "+1 441",
      "name": "Bermuda"
    },
    {
      "code": "+975",
      "name": "Bhutan"
    },
    {
      "code": "+591",
      "name": "Bolivia"
    },
    {
      "code": "+387",
      "name": "Bosnia and Herzegovina"
    },
    {
      "code": "+267",
      "name": "Botswana"
    },
    {
      "code": "+55",
      "name": "Brazil"
    },
    {
      "code": "+246",
      "name": "British Indian Ocean Territory"
    },
    {
      "code": "+1 284",
      "name": "British Virgin Islands"
    },
    {
      "code": "+673",
      "name": "Brunei"
    },
    {
      "code": "+359",
      "name": "Bulgaria"
    },
    {
      "code": "+226",
      "name": "Burkina Faso"
    },
    {
      "code": "+257",
      "name": "Burundi"
    },
    {
      "code": "+855",
      "name": "Cambodia"
    },
    {
      "code": "+237",
      "name": "Cameroon"
    },
    {
      "code": "+1",
      "name": "Canada"
    },
    {
      "code": "+238",
      "name": "Cape Verde"
    },
    {
      "code": "+ 345",
      "name": "Cayman Islands"
    },
    {
      "code": "+236",
      "name": "Central African Republic"
    },
    {
      "code": "+235",
      "name": "Chad"
    },
    {
      "code": "+56",
      "name": "Chile"
    },
    {
      "code": "+86",
      "name": "China"
    },
    {
      "code": "+61",
      "name": "Christmas Island"
    },
    {
      "code": "+61",
      "name": "Cocos-Keeling Islands"
    },
    {
      "code": "+57",
      "name": "Colombia"
    },
    {
      "code": "+269",
      "name": "Comoros"
    },
    {
      "code": "+242",
      "name": "Congo"
    },
    {
      "code": "+243",
      "name": "Congo, Dem. Rep. of (Zaire)"
    },
    {
      "code": "+682",
      "name": "Cook Islands"
    },
    {
      "code": "+506",
      "name": "Costa Rica"
    },
    {
      "code": "+385",
      "name": "Croatia"
    },
    {
      "code": "+53",
      "name": "Cuba"
    },
    {
      "code": "+599",
      "name": "Curacao"
    },
    {
      "code": "+537",
      "name": "Cyprus"
    },
    {
      "code": "+420",
      "name": "Czech Republic"
    },
    {
      "code": "+45",
      "name": "Denmark"
    },
    {
      "code": "+246",
      "name": "Diego Garcia"
    },
    {
      "code": "+253",
      "name": "Djibouti"
    },
    {
      "code": "+1 767",
      "name": "Dominica"
    },
    {
      "code": "+1 809",
      "name": "Dominican Republic"
    },
    {
      "code": "+670",
      "name": "East Timor"
    },
    {
      "code": "+56",
      "name": "Easter Island"
    },
    {
      "code": "+593",
      "name": "Ecuador"
    },
    {
      "code": "+20",
      "name": "Egypt"
    },
    {
      "code": "+503",
      "name": "El Salvador"
    },
    {
      "code": "+240",
      "name": "Equatorial Guinea"
    },
    {
      "code": "+291",
      "name": "Eritrea"
    },
    {
      "code": "+372",
      "name": "Estonia"
    },
    {
      "code": "+251",
      "name": "Ethiopia"
    },
    {
      "code": "+500",
      "name": "Falkland Islands"
    },
    {
      "code": "+298",
      "name": "Faroe Islands"
    },
    {
      "code": "+679",
      "name": "Fiji"
    },
    {
      "code": "+358",
      "name": "Finland"
    },
    {
      "code": "+33",
      "name": "France"
    },
    {
      "code": "+596",
      "name": "French Antilles"
    },
    {
      "code": "+594",
      "name": "French Guiana"
    },
    {
      "code": "+689",
      "name": "French Polynesia"
    },
    {
      "code": "+241",
      "name": "Gabon"
    },
    {
      "code": "+220",
      "name": "Gambia"
    },
    {
      "code": "+995",
      "name": "Georgia"
    },
    {
      "code": "+49",
      "name": "Germany"
    },
    {
      "code": "+233",
      "name": "Ghana"
    },
    {
      "code": "+350",
      "name": "Gibraltar"
    },
    {
      "code": "+30",
      "name": "Greece"
    },
    {
      "code": "+299",
      "name": "Greenland"
    },
    {
      "code": "+1 473",
      "name": "Grenada"
    },
    {
      "code": "+590",
      "name": "Guadeloupe"
    },
    {
      "code": "+1 671",
      "name": "Guam"
    },
    {
      "code": "+502",
      "name": "Guatemala"
    },
    {
      "code": "+224",
      "name": "Guinea"
    },
    {
      "code": "+245",
      "name": "Guinea-Bissau"
    },
    {
      "code": "+595",
      "name": "Guyana"
    },
    {
      "code": "+509",
      "name": "Haiti"
    },
    {
      "code": "+504",
      "name": "Honduras"
    },
    {
      "code": "+852",
      "name": "Hong Kong SAR China"
    },
    {
      "code": "+36",
      "name": "Hungary"
    },
    {
      "code": "+354",
      "name": "Iceland"
    },
    {
      "code": "+91",
      "name": "India"
    },
    {
      "code": "+62",
      "name": "Indonesia"
    },
    {
      "code": "+98",
      "name": "Iran"
    },
    {
      "code": "+964",
      "name": "Iraq"
    },
    {
      "code": "+353",
      "name": "Ireland"
    },
    {
      "code": "+972",
      "name": "Israel"
    },
    {
      "code": "+39",
      "name": "Italy"
    },
    {
      "code": "+225",
      "name": "Ivory Coast"
    },
    {
      "code": "+1 876",
      "name": "Jamaica"
    },
    {
      "code": "+81",
      "name": "Japan"
    },
    {
      "code": "+962",
      "name": "Jordan"
    },
    {
      "code": "+7 7",
      "name": "Kazakhstan"
    },
    {
      "code": "+254",
      "name": "Kenya"
    },
    {
      "code": "+686",
      "name": "Kiribati"
    },
    {
      "code": "+965",
      "name": "Kuwait"
    },
    {
      "code": "+996",
      "name": "Kyrgyzstan"
    },
    {
      "code": "+856",
      "name": "Laos"
    },
    {
      "code": "+371",
      "name": "Latvia"
    },
    {
      "code": "+961",
      "name": "Lebanon"
    },
    {
      "code": "+266",
      "name": "Lesotho"
    },
    {
      "code": "+231",
      "name": "Liberia"
    },
    {
      "code": "+218",
      "name": "Libya"
    },
    {
      "code": "+423",
      "name": "Liechtenstein"
    },
    {
      "code": "+370",
      "name": "Lithuania"
    },
    {
      "code": "+352",
      "name": "Luxembourg"
    },
    {
      "code": "+853",
      "name": "Macau SAR China"
    },
    {
      "code": "+389",
      "name": "Macedonia"
    },
    {
      "code": "+261",
      "name": "Madagascar"
    },
    {
      "code": "+265",
      "name": "Malawi"
    },
    {
      "code": "+60",
      "name": "Malaysia"
    },
    {
      "code": "+960",
      "name": "Maldives"
    },
    {
      "code": "+223",
      "name": "Mali"
    },
    {
      "code": "+356",
      "name": "Malta"
    },
    {
      "code": "+692",
      "name": "Marshall Islands"
    },
    {
      "code": "+596",
      "name": "Martinique"
    },
    {
      "code": "+222",
      "name": "Mauritania"
    },
    {
      "code": "+230",
      "name": "Mauritius"
    },
    {
      "code": "+262",
      "name": "Mayotte"
    },
    {
      "code": "+52",
      "name": "Mexico"
    },
    {
      "code": "+691",
      "name": "Micronesia"
    },
    {
      "code": "+1 808",
      "name": "Midway Island"
    },
    {
      "code": "+373",
      "name": "Moldova"
    },
    {
      "code": "+377",
      "name": "Monaco"
    },
    {
      "code": "+976",
      "name": "Mongolia"
    },
    {
      "code": "+382",
      "name": "Montenegro"
    },
    {
      "code": "+1664",
      "name": "Montserrat"
    },
    {
      "code": "+212",
      "name": "Morocco"
    },
    {
      "code": "+95",
      "name": "Myanmar"
    },
    {
      "code": "+264",
      "name": "Namibia"
    },
    {
      "code": "+674",
      "name": "Nauru"
    },
    {
      "code": "+977",
      "name": "Nepal"
    },
    {
      "code": "+31",
      "name": "Netherlands"
    },
    {
      "code": "+599",
      "name": "Netherlands Antilles"
    },
    {
      "code": "+1 869",
      "name": "Nevis"
    },
    {
      "code": "+687",
      "name": "New Caledonia"
    },
    {
      "code": "+64",
      "name": "New Zealand"
    },
    {
      "code": "+505",
      "name": "Nicaragua"
    },
    {
      "code": "+227",
      "name": "Niger"
    },
    {
      "code": "+234",
      "name": "Nigeria"
    },
    {
      "code": "+683",
      "name": "Niue"
    },
    {
      "code": "+672",
      "name": "Norfolk Island"
    },
    {
      "code": "+850",
      "name": "North Korea"
    },
    {
      "code": "+1 670",
      "name": "Northern Mariana Islands"
    },
    {
      "code": "+47",
      "name": "Norway"
    },
    {
      "code": "+968",
      "name": "Oman"
    },
    {
      "code": "+92",
      "name": "Pakistan"
    },
    {
      "code": "+680",
      "name": "Palau"
    },
    {
      "code": "+970",
      "name": "Palestinian Territory"
    },
    {
      "code": "+507",
      "name": "Panama"
    },
    {
      "code": "+675",
      "name": "Papua New Guinea"
    },
    {
      "code": "+595",
      "name": "Paraguay"
    },
    {
      "code": "+51",
      "name": "Peru"
    },
    {
      "code": "+63",
      "name": "Philippines"
    },
    {
      "code": "+48",
      "name": "Poland"
    },
    {
      "code": "+351",
      "name": "Portugal"
    },
    {
      "code": "+1 787",
      "name": "Puerto Rico"
    },
    {
      "code": "+974",
      "name": "Qatar"
    },
    {
      "code": "+262",
      "name": "Reunion"
    },
    {
      "code": "+40",
      "name": "Romania"
    },
    {
      "code": "+7",
      "name": "Russia"
    },
    {
      "code": "+250",
      "name": "Rwanda"
    },
    {
      "code": "+685",
      "name": "Samoa"
    },
    {
      "code": "+378",
      "name": "San Marino"
    },
    {
      "code": "+966",
      "name": "Saudi Arabia"
    },
    {
      "code": "+221",
      "name": "Senegal"
    },
    {
      "code": "+381",
      "name": "Serbia"
    },
    {
      "code": "+248",
      "name": "Seychelles"
    },
    {
      "code": "+232",
      "name": "Sierra Leone"
    },
    {
      "code": "+65",
      "name": "Singapore"
    },
    {
      "code": "+421",
      "name": "Slovakia"
    },
    {
      "code": "+386",
      "name": "Slovenia"
    },
    {
      "code": "+677",
      "name": "Solomon Islands"
    },
    {
      "code": "+27",
      "name": "South Africa"
    },
    {
      "code": "+500",
      "name": "South Georgia and the South Sandwich Islands"
    },
    {
      "code": "+82",
      "name": "South Korea"
    },
    {
      "code": "+34",
      "name": "Spain"
    },
    {
      "code": "+94",
      "name": "Sri Lanka"
    },
    {
      "code": "+249",
      "name": "Sudan"
    },
    {
      "code": "+597",
      "name": "Suriname"
    },
    {
      "code": "+268",
      "name": "Swaziland"
    },
    {
      "code": "+46",
      "name": "Sweden"
    },
    {
      "code": "+41",
      "name": "Switzerland"
    },
    {
      "code": "+963",
      "name": "Syria"
    },
    {
      "code": "+886",
      "name": "Taiwan"
    },
    {
      "code": "+992",
      "name": "Tajikistan"
    },
    {
      "code": "+255",
      "name": "Tanzania"
    },
    {
      "code": "+66",
      "name": "Thailand"
    },
    {
      "code": "+670",
      "name": "Timor Leste"
    },
    {
      "code": "+228",
      "name": "Togo"
    },
    {
      "code": "+690",
      "name": "Tokelau"
    },
    {
      "code": "+676",
      "name": "Tonga"
    },
    {
      "code": "+1 868",
      "name": "Trinidad and Tobago"
    },
    {
      "code": "+216",
      "name": "Tunisia"
    },
    {
      "code": "+90",
      "name": "Turkey"
    },
    {
      "code": "+993",
      "name": "Turkmenistan"
    },
    {
      "code": "+1 649",
      "name": "Turks and Caicos Islands"
    },
    {
      "code": "+688",
      "name": "Tuvalu"
    },
    {
      "code": "+1 340",
      "name": "U.S. Virgin Islands"
    },
    {
      "code": "+256",
      "name": "Uganda"
    },
    {
      "code": "+380",
      "name": "Ukraine"
    },
    {
      "code": "+971",
      "name": "United Arab Emirates"
    },
    {
      "code": "+44",
      "name": "United Kingdom"
    },
    {
      "code": "+1",
      "name": "United States"
    },
    {
      "code": "+598",
      "name": "Uruguay"
    },
    {
      "code": "+998",
      "name": "Uzbekistan"
    },
    {
      "code": "+678",
      "name": "Vanuatu"
    },
    {
      "code": "+58",
      "name": "Venezuela"
    },
    {
      "code": "+84",
      "name": "Vietnam"
    },
    {
      "code": "+1 808",
      "name": "Wake Island"
    },
    {
      "code": "+681",
      "name": "Wallis and Futuna"
    },
    {
      "code": "+967",
      "name": "Yemen"
    },
    {
      "code": "+260",
      "name": "Zambia"
    },
    {
      "code": "+255",
      "name": "Zanzibar"
    },
    {
      "code": "+263",
      "name": "Zimbabwe"
    }
  ]
}
于 2015-01-29T22:48:00.390 回答
30

您可以从http://country.io/phone.json获取将国家/地区代码映射到电话代码的 JSON 文件:

...
BD: "880",
BE: "32",
BF: "226",
BG: "359",
BA: "387",
...

如果您想要国家/地区名称,那么http://country.io/names.json将为您提供:

...
"AL": "Albania",
"AM": "Armenia",
"AO": "Angola",
"AQ": "Antarctica",
"AR": "Argentina",
...

有关详细信息,请参阅http://country.io/data 。

于 2014-09-05T01:51:10.703 回答
23

这里有一个带有正则表达式的 Excel 文件。您可以轻松地将其“转换”为 XML,并且您将能够通过完整的电话号码确定国家/地区。

UPD:我 4 年前引用的文件已无法访问。我会推荐使用谷歌的 libphonenumber

从电话号码 [libphonenumber] 中提取代码国家的答案将向您展示从电话号码接收国家代码的正确方法。

于 2010-03-27T18:30:28.167 回答
12

在 github上有一个维护得相当好的repo,它有一个 CSV(带有分号分隔符)、XML 和 JSON 来源的国家、国家代码和其他信息。

于 2013-11-07T17:30:35.383 回答
8

我强烈建议您使用Google 的 libphonenumber 项目,而不是尝试使用您自己的逻辑来确定电话号码的国家代码。该项目非常广泛且维护良好,并且已被移植到多种语言。

于 2013-01-25T15:10:21.453 回答
5

您可以使用在线转换器轻松转换为 xml 格式:

我已经转换了列表:

<?xml version="1.0" encoding="UTF-8" ?>
<countries>
    <code>+7 840</code>
    <name>Abkhazia</name>
</countries>
<countries>
    <code>+93</code>
    <name>Afghanistan</name>
</countries>
<countries>
    <code>+355</code>
    <name>Albania</name>
</countries>
<countries>
    <code>+213</code>
    <name>Algeria</name>
</countries>
<countries>
    <code>+1 684</code>
    <name>American Samoa</name>
</countries>
<countries>
    <code>+376</code>
    <name>Andorra</name>
</countries>
<countries>
    <code>+244</code>
    <name>Angola</name>
</countries>
<countries>
    <code>+1 264</code>
    <name>Anguilla</name>
</countries>
<countries>
    <code>+1 268</code>
    <name>Antigua and Barbuda</name>
</countries>
<countries>
    <code>+54</code>
    <name>Argentina</name>
</countries>
<countries>
    <code>+374</code>
    <name>Armenia</name>
</countries>
<countries>
    <code>+297</code>
    <name>Aruba</name>
</countries>
<countries>
    <code>+247</code>
    <name>Ascension</name>
</countries>
<countries>
    <code>+61</code>
    <name>Australia</name>
</countries>
<countries>
    <code>+672</code>
    <name>Australian External Territories</name>
</countries>
<countries>
    <code>+43</code>
    <name>Austria</name>
</countries>
<countries>
    <code>+994</code>
    <name>Azerbaijan</name>
</countries>
<countries>
    <code>+1 242</code>
    <name>Bahamas</name>
</countries>
<countries>
    <code>+973</code>
    <name>Bahrain</name>
</countries>
<countries>
    <code>+880</code>
    <name>Bangladesh</name>
</countries>
<countries>
    <code>+1 246</code>
    <name>Barbados</name>
</countries>
<countries>
    <code>+1 268</code>
    <name>Barbuda</name>
</countries>
<countries>
    <code>+375</code>
    <name>Belarus</name>
</countries>
<countries>
    <code>+32</code>
    <name>Belgium</name>
</countries>
<countries>
    <code>+501</code>
    <name>Belize</name>
</countries>
<countries>
    <code>+229</code>
    <name>Benin</name>
</countries>
<countries>
    <code>+1 441</code>
    <name>Bermuda</name>
</countries>
<countries>
    <code>+975</code>
    <name>Bhutan</name>
</countries>
<countries>
    <code>+591</code>
    <name>Bolivia</name>
</countries>
<countries>
    <code>+387</code>
    <name>Bosnia and Herzegovina</name>
</countries>
<countries>
    <code>+267</code>
    <name>Botswana</name>
</countries>
<countries>
    <code>+55</code>
    <name>Brazil</name>
</countries>
<countries>
    <code>+246</code>
    <name>British Indian Ocean Territory</name>
</countries>
<countries>
    <code>+1 284</code>
    <name>British Virgin Islands</name>
</countries>
<countries>
    <code>+673</code>
    <name>Brunei</name>
</countries>
<countries>
    <code>+359</code>
    <name>Bulgaria</name>
</countries>
<countries>
    <code>+226</code>
    <name>Burkina Faso</name>
</countries>
<countries>
    <code>+257</code>
    <name>Burundi</name>
</countries>
<countries>
    <code>+855</code>
    <name>Cambodia</name>
</countries>
<countries>
    <code>+237</code>
    <name>Cameroon</name>
</countries>
<countries>
    <code>+1</code>
    <name>Canada</name>
</countries>
<countries>
    <code>+238</code>
    <name>Cape Verde</name>
</countries>
<countries>
    <code>+ 345</code>
    <name>Cayman Islands</name>
</countries>
<countries>
    <code>+236</code>
    <name>Central African Republic</name>
</countries>
<countries>
    <code>+235</code>
    <name>Chad</name>
</countries>
<countries>
    <code>+56</code>
    <name>Chile</name>
</countries>
<countries>
    <code>+86</code>
    <name>China</name>
</countries>
<countries>
    <code>+61</code>
    <name>Christmas Island</name>
</countries>
<countries>
    <code>+61</code>
    <name>Cocos-Keeling Islands</name>
</countries>
<countries>
    <code>+57</code>
    <name>Colombia</name>
</countries>
<countries>
    <code>+269</code>
    <name>Comoros</name>
</countries>
<countries>
    <code>+242</code>
    <name>Congo</name>
</countries>
<countries>
    <code>+243</code>
    <name>Congo, Dem. Rep. of (Zaire)</name>
</countries>
<countries>
    <code>+682</code>
    <name>Cook Islands</name>
</countries>
<countries>
    <code>+506</code>
    <name>Costa Rica</name>
</countries>
<countries>
    <code>+385</code>
    <name>Croatia</name>
</countries>
<countries>
    <code>+53</code>
    <name>Cuba</name>
</countries>
<countries>
    <code>+599</code>
    <name>Curacao</name>
</countries>
<countries>
    <code>+537</code>
    <name>Cyprus</name>
</countries>
<countries>
    <code>+420</code>
    <name>Czech Republic</name>
</countries>
<countries>
    <code>+45</code>
    <name>Denmark</name>
</countries>
<countries>
    <code>+246</code>
    <name>Diego Garcia</name>
</countries>
<countries>
    <code>+253</code>
    <name>Djibouti</name>
</countries>
<countries>
    <code>+1 767</code>
    <name>Dominica</name>
</countries>
<countries>
    <code>+1 809</code>
    <name>Dominican Republic</name>
</countries>
<countries>
    <code>+670</code>
    <name>East Timor</name>
</countries>
<countries>
    <code>+56</code>
    <name>Easter Island</name>
</countries>
<countries>
    <code>+593</code>
    <name>Ecuador</name>
</countries>
<countries>
    <code>+20</code>
    <name>Egypt</name>
</countries>
<countries>
    <code>+503</code>
    <name>El Salvador</name>
</countries>
<countries>
    <code>+240</code>
    <name>Equatorial Guinea</name>
</countries>
<countries>
    <code>+291</code>
    <name>Eritrea</name>
</countries>
<countries>
    <code>+372</code>
    <name>Estonia</name>
</countries>
<countries>
    <code>+251</code>
    <name>Ethiopia</name>
</countries>
<countries>
    <code>+500</code>
    <name>Falkland Islands</name>
</countries>
<countries>
    <code>+298</code>
    <name>Faroe Islands</name>
</countries>
<countries>
    <code>+679</code>
    <name>Fiji</name>
</countries>
<countries>
    <code>+358</code>
    <name>Finland</name>
</countries>
<countries>
    <code>+33</code>
    <name>France</name>
</countries>
<countries>
    <code>+596</code>
    <name>French Antilles</name>
</countries>
<countries>
    <code>+594</code>
    <name>French Guiana</name>
</countries>
<countries>
    <code>+689</code>
    <name>French Polynesia</name>
</countries>
<countries>
    <code>+241</code>
    <name>Gabon</name>
</countries>
<countries>
    <code>+220</code>
    <name>Gambia</name>
</countries>
<countries>
    <code>+995</code>
    <name>Georgia</name>
</countries>
<countries>
    <code>+49</code>
    <name>Germany</name>
</countries>
<countries>
    <code>+233</code>
    <name>Ghana</name>
</countries>
<countries>
    <code>+350</code>
    <name>Gibraltar</name>
</countries>
<countries>
    <code>+30</code>
    <name>Greece</name>
</countries>
<countries>
    <code>+299</code>
    <name>Greenland</name>
</countries>
<countries>
    <code>+1 473</code>
    <name>Grenada</name>
</countries>
<countries>
    <code>+590</code>
    <name>Guadeloupe</name>
</countries>
<countries>
    <code>+1 671</code>
    <name>Guam</name>
</countries>
<countries>
    <code>+502</code>
    <name>Guatemala</name>
</countries>
<countries>
    <code>+224</code>
    <name>Guinea</name>
</countries>
<countries>
    <code>+245</code>
    <name>Guinea-Bissau</name>
</countries>
<countries>
    <code>+595</code>
    <name>Guyana</name>
</countries>
<countries>
    <code>+509</code>
    <name>Haiti</name>
</countries>
<countries>
    <code>+504</code>
    <name>Honduras</name>
</countries>
<countries>
    <code>+852</code>
    <name>Hong Kong SAR China</name>
</countries>
<countries>
    <code>+36</code>
    <name>Hungary</name>
</countries>
<countries>
    <code>+354</code>
    <name>Iceland</name>
</countries>
<countries>
    <code>+91</code>
    <name>India</name>
</countries>
<countries>
    <code>+62</code>
    <name>Indonesia</name>
</countries>
<countries>
    <code>+98</code>
    <name>Iran</name>
</countries>
<countries>
    <code>+964</code>
    <name>Iraq</name>
</countries>
<countries>
    <code>+353</code>
    <name>Ireland</name>
</countries>
<countries>
    <code>+972</code>
    <name>Israel</name>
</countries>
<countries>
    <code>+39</code>
    <name>Italy</name>
</countries>
<countries>
    <code>+225</code>
    <name>Ivory Coast</name>
</countries>
<countries>
    <code>+1 876</code>
    <name>Jamaica</name>
</countries>
<countries>
    <code>+81</code>
    <name>Japan</name>
</countries>
<countries>
    <code>+962</code>
    <name>Jordan</name>
</countries>
<countries>
    <code>+7 7</code>
    <name>Kazakhstan</name>
</countries>
<countries>
    <code>+254</code>
    <name>Kenya</name>
</countries>
<countries>
    <code>+686</code>
    <name>Kiribati</name>
</countries>
<countries>
    <code>+965</code>
    <name>Kuwait</name>
</countries>
<countries>
    <code>+996</code>
    <name>Kyrgyzstan</name>
</countries>
<countries>
    <code>+856</code>
    <name>Laos</name>
</countries>
<countries>
    <code>+371</code>
    <name>Latvia</name>
</countries>
<countries>
    <code>+961</code>
    <name>Lebanon</name>
</countries>
<countries>
    <code>+266</code>
    <name>Lesotho</name>
</countries>
<countries>
    <code>+231</code>
    <name>Liberia</name>
</countries>
<countries>
    <code>+218</code>
    <name>Libya</name>
</countries>
<countries>
    <code>+423</code>
    <name>Liechtenstein</name>
</countries>
<countries>
    <code>+370</code>
    <name>Lithuania</name>
</countries>
<countries>
    <code>+352</code>
    <name>Luxembourg</name>
</countries>
<countries>
    <code>+853</code>
    <name>Macau SAR China</name>
</countries>
<countries>
    <code>+389</code>
    <name>Macedonia</name>
</countries>
<countries>
    <code>+261</code>
    <name>Madagascar</name>
</countries>
<countries>
    <code>+265</code>
    <name>Malawi</name>
</countries>
<countries>
    <code>+60</code>
    <name>Malaysia</name>
</countries>
<countries>
    <code>+960</code>
    <name>Maldives</name>
</countries>
<countries>
    <code>+223</code>
    <name>Mali</name>
</countries>
<countries>
    <code>+356</code>
    <name>Malta</name>
</countries>
<countries>
    <code>+692</code>
    <name>Marshall Islands</name>
</countries>
<countries>
    <code>+596</code>
    <name>Martinique</name>
</countries>
<countries>
    <code>+222</code>
    <name>Mauritania</name>
</countries>
<countries>
    <code>+230</code>
    <name>Mauritius</name>
</countries>
<countries>
    <code>+262</code>
    <name>Mayotte</name>
</countries>
<countries>
    <code>+52</code>
    <name>Mexico</name>
</countries>
<countries>
    <code>+691</code>
    <name>Micronesia</name>
</countries>
<countries>
    <code>+1 808</code>
    <name>Midway Island</name>
</countries>
<countries>
    <code>+373</code>
    <name>Moldova</name>
</countries>
<countries>
    <code>+377</code>
    <name>Monaco</name>
</countries>
<countries>
    <code>+976</code>
    <name>Mongolia</name>
</countries>
<countries>
    <code>+382</code>
    <name>Montenegro</name>
</countries>
<countries>
    <code>+1664</code>
    <name>Montserrat</name>
</countries>
<countries>
    <code>+212</code>
    <name>Morocco</name>
</countries>
<countries>
    <code>+95</code>
    <name>Myanmar</name>
</countries>
<countries>
    <code>+264</code>
    <name>Namibia</name>
</countries>
<countries>
    <code>+674</code>
    <name>Nauru</name>
</countries>
<countries>
    <code>+977</code>
    <name>Nepal</name>
</countries>
<countries>
    <code>+31</code>
    <name>Netherlands</name>
</countries>
<countries>
    <code>+599</code>
    <name>Netherlands Antilles</name>
</countries>
<countries>
    <code>+1 869</code>
    <name>Nevis</name>
</countries>
<countries>
    <code>+687</code>
    <name>New Caledonia</name>
</countries>
<countries>
    <code>+64</code>
    <name>New Zealand</name>
</countries>
<countries>
    <code>+505</code>
    <name>Nicaragua</name>
</countries>
<countries>
    <code>+227</code>
    <name>Niger</name>
</countries>
<countries>
    <code>+234</code>
    <name>Nigeria</name>
</countries>
<countries>
    <code>+683</code>
    <name>Niue</name>
</countries>
<countries>
    <code>+672</code>
    <name>Norfolk Island</name>
</countries>
<countries>
    <code>+850</code>
    <name>North Korea</name>
</countries>
<countries>
    <code>+1 670</code>
    <name>Northern Mariana Islands</name>
</countries>
<countries>
    <code>+47</code>
    <name>Norway</name>
</countries>
<countries>
    <code>+968</code>
    <name>Oman</name>
</countries>
<countries>
    <code>+92</code>
    <name>Pakistan</name>
</countries>
<countries>
    <code>+680</code>
    <name>Palau</name>
</countries>
<countries>
    <code>+970</code>
    <name>Palestinian Territory</name>
</countries>
<countries>
    <code>+507</code>
    <name>Panama</name>
</countries>
<countries>
    <code>+675</code>
    <name>Papua New Guinea</name>
</countries>
<countries>
    <code>+595</code>
    <name>Paraguay</name>
</countries>
<countries>
    <code>+51</code>
    <name>Peru</name>
</countries>
<countries>
    <code>+63</code>
    <name>Philippines</name>
</countries>
<countries>
    <code>+48</code>
    <name>Poland</name>
</countries>
<countries>
    <code>+351</code>
    <name>Portugal</name>
</countries>
<countries>
    <code>+1 787</code>
    <name>Puerto Rico</name>
</countries>
<countries>
    <code>+974</code>
    <name>Qatar</name>
</countries>
<countries>
    <code>+262</code>
    <name>Reunion</name>
</countries>
<countries>
    <code>+40</code>
    <name>Romania</name>
</countries>
<countries>
    <code>+7</code>
    <name>Russia</name>
</countries>
<countries>
    <code>+250</code>
    <name>Rwanda</name>
</countries>
<countries>
    <code>+685</code>
    <name>Samoa</name>
</countries>
<countries>
    <code>+378</code>
    <name>San Marino</name>
</countries>
<countries>
    <code>+966</code>
    <name>Saudi Arabia</name>
</countries>
<countries>
    <code>+221</code>
    <name>Senegal</name>
</countries>
<countries>
    <code>+381</code>
    <name>Serbia</name>
</countries>
<countries>
    <code>+248</code>
    <name>Seychelles</name>
</countries>
<countries>
    <code>+232</code>
    <name>Sierra Leone</name>
</countries>
<countries>
    <code>+65</code>
    <name>Singapore</name>
</countries>
<countries>
    <code>+421</code>
    <name>Slovakia</name>
</countries>
<countries>
    <code>+386</code>
    <name>Slovenia</name>
</countries>
<countries>
    <code>+677</code>
    <name>Solomon Islands</name>
</countries>
<countries>
    <code>+27</code>
    <name>South Africa</name>
</countries>
<countries>
    <code>+500</code>
    <name>South Georgia and the South Sandwich Islands</name>
</countries>
<countries>
    <code>+82</code>
    <name>South Korea</name>
</countries>
<countries>
    <code>+34</code>
    <name>Spain</name>
</countries>
<countries>
    <code>+94</code>
    <name>Sri Lanka</name>
</countries>
<countries>
    <code>+249</code>
    <name>Sudan</name>
</countries>
<countries>
    <code>+597</code>
    <name>Suriname</name>
</countries>
<countries>
    <code>+268</code>
    <name>Swaziland</name>
</countries>
<countries>
    <code>+46</code>
    <name>Sweden</name>
</countries>
<countries>
    <code>+41</code>
    <name>Switzerland</name>
</countries>
<countries>
    <code>+963</code>
    <name>Syria</name>
</countries>
<countries>
    <code>+886</code>
    <name>Taiwan</name>
</countries>
<countries>
    <code>+992</code>
    <name>Tajikistan</name>
</countries>
<countries>
    <code>+255</code>
    <name>Tanzania</name>
</countries>
<countries>
    <code>+66</code>
    <name>Thailand</name>
</countries>
<countries>
    <code>+670</code>
    <name>Timor Leste</name>
</countries>
<countries>
    <code>+228</code>
    <name>Togo</name>
</countries>
<countries>
    <code>+690</code>
    <name>Tokelau</name>
</countries>
<countries>
    <code>+676</code>
    <name>Tonga</name>
</countries>
<countries>
    <code>+1 868</code>
    <name>Trinidad and Tobago</name>
</countries>
<countries>
    <code>+216</code>
    <name>Tunisia</name>
</countries>
<countries>
    <code>+90</code>
    <name>Turkey</name>
</countries>
<countries>
    <code>+993</code>
    <name>Turkmenistan</name>
</countries>
<countries>
    <code>+1 649</code>
    <name>Turks and Caicos Islands</name>
</countries>
<countries>
    <code>+688</code>
    <name>Tuvalu</name>
</countries>
<countries>
    <code>+1 340</code>
    <name>U.S. Virgin Islands</name>
</countries>
<countries>
    <code>+256</code>
    <name>Uganda</name>
</countries>
<countries>
    <code>+380</code>
    <name>Ukraine</name>
</countries>
<countries>
    <code>+971</code>
    <name>United Arab Emirates</name>
</countries>
<countries>
    <code>+44</code>
    <name>United Kingdom</name>
</countries>
<countries>
    <code>+1</code>
    <name>United States</name>
</countries>
<countries>
    <code>+598</code>
    <name>Uruguay</name>
</countries>
<countries>
    <code>+998</code>
    <name>Uzbekistan</name>
</countries>
<countries>
    <code>+678</code>
    <name>Vanuatu</name>
</countries>
<countries>
    <code>+58</code>
    <name>Venezuela</name>
</countries>
<countries>
    <code>+84</code>
    <name>Vietnam</name>
</countries>
<countries>
    <code>+1 808</code>
    <name>Wake Island</name>
</countries>
<countries>
    <code>+681</code>
    <name>Wallis and Futuna</name>
</countries>
<countries>
    <code>+967</code>
    <name>Yemen</name>
</countries>
<countries>
    <code>+260</code>
    <name>Zambia</name>
</countries>
<countries>
    <code>+255</code>
    <name>Zanzibar</name>
</countries>
<countries>
    <code>+263</code>
    <name>Zimbabwe</name>
</countries>
于 2016-04-27T15:53:14.210 回答
3

这是一个将“国家代码”(ISO3)转换为电话“呼叫代码”的 JS 函数:

function country_iso3_to_country_calling_code(country_iso3) {
        if(country_iso3 == 'AFG') return '93';
        if(country_iso3 == 'ALB') return '355';
        if(country_iso3 == 'DZA') return '213';
        if(country_iso3 == 'ASM') return '1684';
        if(country_iso3 == 'AND') return '376';
        if(country_iso3 == 'AGO') return '244';
        if(country_iso3 == 'AIA') return '1264';
        if(country_iso3 == 'ATA') return '672';
        if(country_iso3 == 'ATG') return '1268';
        if(country_iso3 == 'ARG') return '54';
        if(country_iso3 == 'ARM') return '374';
        if(country_iso3 == 'ABW') return '297';
        if(country_iso3 == 'AUS') return '61';
        if(country_iso3 == 'AUT') return '43';
        if(country_iso3 == 'AZE') return '994';
        if(country_iso3 == 'BHS') return '1242';
        if(country_iso3 == 'BHR') return '973';
        if(country_iso3 == 'BGD') return '880';
        if(country_iso3 == 'BRB') return '1246';
        if(country_iso3 == 'BLR') return '375';
        if(country_iso3 == 'BEL') return '32';
        if(country_iso3 == 'BLZ') return '501';
        if(country_iso3 == 'BEN') return '229';
        if(country_iso3 == 'BMU') return '1441';
        if(country_iso3 == 'BTN') return '975';
        if(country_iso3 == 'BOL') return '591';
        if(country_iso3 == 'BIH') return '387';
        if(country_iso3 == 'BWA') return '267';
        if(country_iso3 == 'BVT') return '_55';
        if(country_iso3 == 'BRA') return '55';
        if(country_iso3 == 'IOT') return '1284';
        if(country_iso3 == 'BRN') return '673';
        if(country_iso3 == 'BGR') return '359';
        if(country_iso3 == 'BFA') return '226';
        if(country_iso3 == 'BDI') return '257';
        if(country_iso3 == 'KHM') return '855';
        if(country_iso3 == 'CMR') return '237';
        if(country_iso3 == 'CAN') return '1';
        if(country_iso3 == 'CPV') return '238';
        if(country_iso3 == 'CYM') return '1345';
        if(country_iso3 == 'CAF') return '236';
        if(country_iso3 == 'TCD') return '235';
        if(country_iso3 == 'CHL') return '56';
        if(country_iso3 == 'CHN') return '86';
        if(country_iso3 == 'CXR') return '618';
        if(country_iso3 == 'CCK') return '61';
        if(country_iso3 == 'COL') return '57';
        if(country_iso3 == 'COM') return '269';
        if(country_iso3 == 'COG') return '242';
        if(country_iso3 == 'COD') return '243';
        if(country_iso3 == 'COK') return '682';
        if(country_iso3 == 'CRI') return '506';
        if(country_iso3 == 'HRV') return '385';
        if(country_iso3 == 'CUB') return '53';
        if(country_iso3 == 'CYP') return '357';
        if(country_iso3 == 'CZE') return '420';
        if(country_iso3 == 'DNK') return '45';
        if(country_iso3 == 'DJI') return '253';
        if(country_iso3 == 'DMA') return '1767';
        if(country_iso3 == 'DOM') return '1';
        if(country_iso3 == 'ECU') return '593';
        if(country_iso3 == 'EGY') return '20';
        if(country_iso3 == 'SLV') return '503';
        if(country_iso3 == 'GNQ') return '240';
        if(country_iso3 == 'ERI') return '291';
        if(country_iso3 == 'EST') return '372';
        if(country_iso3 == 'ETH') return '251';
        if(country_iso3 == 'FLK') return '500';
        if(country_iso3 == 'FRO') return '298';
        if(country_iso3 == 'FJI') return '679';
        if(country_iso3 == 'FIN') return '358';
        if(country_iso3 == 'FRA') return '33';
        if(country_iso3 == 'GUF') return '594';
        if(country_iso3 == 'PYF') return '689';
        if(country_iso3 == 'GAB') return '241';
        if(country_iso3 == 'GMB') return '220';
        if(country_iso3 == 'GEO') return '995';
        if(country_iso3 == 'DEU') return '49';
        if(country_iso3 == 'GHA') return '233';
        if(country_iso3 == 'GIB') return '350';
        if(country_iso3 == 'GRC') return '30';
        if(country_iso3 == 'GRL') return '299';
        if(country_iso3 == 'GRD') return '1473';
        if(country_iso3 == 'GLP') return '590';
        if(country_iso3 == 'GUM') return '1671';
        if(country_iso3 == 'GTM') return '502';
        if(country_iso3 == 'GIN') return '224';
        if(country_iso3 == 'GNB') return '245';
        if(country_iso3 == 'GUY') return '592';
        if(country_iso3 == 'HTI') return '509';
        if(country_iso3 == 'HMD') return '61';
        if(country_iso3 == 'VAT') return '3';
        if(country_iso3 == 'HND') return '504';
        if(country_iso3 == 'HKG') return '852';
        if(country_iso3 == 'HUN') return '36';
        if(country_iso3 == 'ISL') return '354';
        if(country_iso3 == 'IND') return '91';
        if(country_iso3 == 'IDN') return '62';
        if(country_iso3 == 'IRN') return '98';
        if(country_iso3 == 'IRQ') return '964';
        if(country_iso3 == 'IRL') return '353';
        if(country_iso3 == 'ISR') return '972';
        if(country_iso3 == 'ITA') return '39';
        if(country_iso3 == 'CIV') return '225';
        if(country_iso3 == 'JAM') return '1876';
        if(country_iso3 == 'JPN') return '81';
        if(country_iso3 == 'JOR') return '962';
        if(country_iso3 == 'KAZ') return '7';
        if(country_iso3 == 'KEN') return '254';
        if(country_iso3 == 'KIR') return '686';
        if(country_iso3 == 'PRK') return '850';
        if(country_iso3 == 'KOR') return '82';
        if(country_iso3 == 'KWT') return '965';
        if(country_iso3 == 'KGZ') return '7';
        if(country_iso3 == 'LAO') return '856';
        if(country_iso3 == 'LVA') return '371';
        if(country_iso3 == 'LBN') return '961';
        if(country_iso3 == 'LSO') return '266';
        if(country_iso3 == 'LBR') return '231';
        if(country_iso3 == 'LBY') return '218';
        if(country_iso3 == 'LIE') return '423';
        if(country_iso3 == 'LTU') return '370';
        if(country_iso3 == 'LUX') return '352';
        if(country_iso3 == 'MAC') return '853';
        if(country_iso3 == 'MKD') return '389';
        if(country_iso3 == 'MDG') return '261';
        if(country_iso3 == 'MWI') return '265';
        if(country_iso3 == 'MYS') return '60';
        if(country_iso3 == 'MDV') return '960';
        if(country_iso3 == 'MLI') return '223';
        if(country_iso3 == 'MLT') return '356';
        if(country_iso3 == 'MHL') return '692';
        if(country_iso3 == 'MTQ') return '596';
        if(country_iso3 == 'MRT') return '222';
        if(country_iso3 == 'MUS') return '230';
        if(country_iso3 == 'MYT') return '262';
        if(country_iso3 == 'MEX') return '52';
        if(country_iso3 == 'FSM') return '691';
        if(country_iso3 == 'MDA') return '373';
        if(country_iso3 == 'MCO') return '377';
        if(country_iso3 == 'MNG') return '976';
        if(country_iso3 == 'MSR') return '1664';
        if(country_iso3 == 'MAR') return '212';
        if(country_iso3 == 'MOZ') return '258';
        if(country_iso3 == 'MMR') return '95';
        if(country_iso3 == 'NAM') return '264';
        if(country_iso3 == 'NRU') return '674';
        if(country_iso3 == 'NPL') return '977';
        if(country_iso3 == 'NLD') return '31';
        if(country_iso3 == 'ANT') return '599';
        if(country_iso3 == 'NCL') return '687';
        if(country_iso3 == 'NZL') return '64';
        if(country_iso3 == 'NIC') return '505';
        if(country_iso3 == 'NER') return '227';
        if(country_iso3 == 'NGA') return '234';
        if(country_iso3 == 'NIU') return '683';
        if(country_iso3 == 'NFK') return '672';
        if(country_iso3 == 'MNP') return '1670';
        if(country_iso3 == 'NOR') return '47';
        if(country_iso3 == 'OMN') return '968';
        if(country_iso3 == 'PAK') return '92';
        if(country_iso3 == 'PLW') return '680';
        if(country_iso3 == 'PSE') return '970';
        if(country_iso3 == 'PAN') return '507';
        if(country_iso3 == 'PNG') return '675';
        if(country_iso3 == 'PRY') return '595';
        if(country_iso3 == 'PER') return '51';
        if(country_iso3 == 'PHL') return '63';
        if(country_iso3 == 'PCN') return '870';
        if(country_iso3 == 'POL') return '48';
        if(country_iso3 == 'PRT') return '351';
        if(country_iso3 == 'PRI') return '1';
        if(country_iso3 == 'QAT') return '974';
        if(country_iso3 == 'REU') return '262';
        if(country_iso3 == 'ROM') return '40';
        if(country_iso3 == 'RUS') return '7';
        if(country_iso3 == 'RWA') return '250';
        if(country_iso3 == 'SHN') return '290';
        if(country_iso3 == 'KNA') return '1869';
        if(country_iso3 == 'LCA') return '1758';
        if(country_iso3 == 'SPM') return '508';
        if(country_iso3 == 'VCT') return '1758';
        if(country_iso3 == 'WSM') return '685';
        if(country_iso3 == 'SMR') return '378';
        if(country_iso3 == 'STP') return '239';
        if(country_iso3 == 'SAU') return '966';
        if(country_iso3 == 'SEN') return '221';
        if(country_iso3 == 'SRB') return '381';
        if(country_iso3 == 'SYC') return '248';
        if(country_iso3 == 'SLE') return '232';
        if(country_iso3 == 'SGP') return '65';
        if(country_iso3 == 'SVK') return '421';
        if(country_iso3 == 'SVN') return '386';
        if(country_iso3 == 'SLB') return '677';
        if(country_iso3 == 'SOM') return '252';
        if(country_iso3 == 'ZAF') return '27';
        if(country_iso3 == 'SGS') return '44';
        if(country_iso3 == 'ESP') return '34';
        if(country_iso3 == 'LKA') return '94';
        if(country_iso3 == 'SDN') return '249';
        if(country_iso3 == 'SUR') return '597';
        if(country_iso3 == 'SJM') return '47';
        if(country_iso3 == 'SWZ') return '268';
        if(country_iso3 == 'SWE') return '46';
        if(country_iso3 == 'CHE') return '41';
        if(country_iso3 == 'SYR') return '963';
        if(country_iso3 == 'TWN') return '886';
        if(country_iso3 == 'TJK') return '992';
        if(country_iso3 == 'TZA') return '255';
        if(country_iso3 == 'THA') return '66';
        if(country_iso3 == 'TLS') return '670';
        if(country_iso3 == 'TGO') return '228';
        if(country_iso3 == 'TKL') return '690';
        if(country_iso3 == 'TON') return '676';
        if(country_iso3 == 'TTO') return '1868';
        if(country_iso3 == 'TUN') return '216';
        if(country_iso3 == 'TUR') return '90';
        if(country_iso3 == 'TKM') return '993';
        if(country_iso3 == 'TCA') return '1649';
        if(country_iso3 == 'TUV') return '688';
        if(country_iso3 == 'UGA') return '256';
        if(country_iso3 == 'UKR') return '380';
        if(country_iso3 == 'ARE') return '971';
        if(country_iso3 == 'GBR') return '44';
        if(country_iso3 == 'USA') return '1';
        if(country_iso3 == 'UMI') return '1340';
        if(country_iso3 == 'URY') return '598';
        if(country_iso3 == 'UZB') return '998';
        if(country_iso3 == 'VUT') return '678';
        if(country_iso3 == 'VEN') return '58';
        if(country_iso3 == 'VNM') return '84';
        if(country_iso3 == 'VGB') return '1284';
        if(country_iso3 == 'VIR') return '1340';
        if(country_iso3 == 'WLF') return '681';
        if(country_iso3 == 'YEM') return '260';
        if(country_iso3 == 'ZMB') return '260';
        if(country_iso3 == 'ZWE') return '263';


    }
于 2016-04-24T01:04:04.537 回答
2

Android 就绪县列表标志图像

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- country list -->
    <string-array name="data000">
        <item name="code">+93</item>
        <item name="country">Afghanistan</item>
        <item name="iso">AF</item>
        <item name="flag">@drawable/afghanistan</item>
    </string-array>
    <string-array name="data001">
        <item name="code">+355</item>
        <item name="country">Albania</item>
        <item name="iso">AL</item>
        <item name="flag">@drawable/albania</item>
    </string-array>
    ...

    <array name="countries">
        <item>@array/data000</item>
        <item>@array/data001</item>
        ...
    </array>
</resources>
于 2015-02-17T06:22:59.997 回答
1

国家数据 NPM 包

如果您一般使用 node 或 NPM,您应该查看完整的Country Data 包

由于您试图通过电话号码获取国家/地区,因此您面临两个主要障碍:

  1. 解析电话号码以获取国家代码。

  2. 处理国家代码可以属于多个国家的情况。例如“+1”的国家代码属于美国和加拿大。

但是,Country Data 包将允许您执行以下操作:

var CountryDataLookup = require('country-data').lookup;

lookup.countries({countryCallingCodes: '+1'})

这些是返回的对象:

[ { alpha2: 'CA',
    alpha3: 'CAN',
    countryCallingCodes: [ '+1' ],
    currencies: [ 'CAD' ],
    ioc: 'CAN',
    languages: [ 'eng', 'fra' ],
    name: 'Canada',
    status: 'assigned' },
  { alpha2: 'UM',
    alpha3: 'UMI',
    countryCallingCodes: [ '+1' ],
    currencies: [ 'USD' ],
    ioc: '',
    languages: [ 'eng' ],
    name: 'United States Minor Outlying Islands',
    status: 'assigned' },
  { alpha2: 'US',
    alpha3: 'USA',
    countryCallingCodes: [ '+1' ],
    currencies: [ 'USD' ],
    ioc: 'USA',
    languages: [ 'eng' ],
    name: 'United States',
    status: 'assigned' } ]
于 2016-05-10T01:52:52.880 回答
0

出于多种原因,我更喜欢构建数据而不是第三方库,而且这些数据是常量。所以为我的目的生成了这个json。可能对每个人都有用。

样本数据格式

[
  {
    "continent_name": "Europe",
    "country_code": "AD",
    "country_name": "Andorra",
    "continent_code": "EU",
    "capital_name": "Andorra la Vella",
    "currency_code": "EUR",
    "phone_code": "376",
    "three_letter_country_code": "AND"
  },
  {
    "continent_name": "Asia",
    "country_code": "AE",
    "country_name": "United Arab Emirates",
    "continent_code": "AS",
    "capital_name": "Abu Dhabi",
    "currency_code": "AED",
    "phone_code": "971",
    "three_letter_country_code": "ARE"
  },
  {
    "continent_name": "Asia",
    "country_code": "AF",
    "country_name": "Afghanistan",
    "continent_code": "AS",
    "capital_name": "Kabul",
    "currency_code": "AFN",
    "phone_code": "93",
    "three_letter_country_code": "AFG"
  }
]

文件中的国家数量 - 249

来源

干杯!

于 2021-09-18T09:53:48.980 回答