Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Convert country/domain codes to full name (ie AU to Australia)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBWin/PBCC Convert country/domain codes to full name (ie AU to Australia)

    Just a simple lil function to convert country/domain codes to their full name (ie. convert "AU" to "Australia"), which I needed because the IP-to-geolocation code I just posted only stores country codes.

    To create a reverse function (ie CountryToCountryCode) simply reverse the order of the strings ... but I'll leave that as an exercise to the user :shhh:

    Code:
    FUNCTION CountryCodeToCountry(sCode AS STRING) AS STRING
    LOCAL r AS STRING
    SELECT CASE UCASE$(sCode)
    CASE "AD": r = "Andorra"
    CASE "AE": r = "United Arab Emirates"
    CASE "AF": r = "Afghanistan"
    CASE "AG": r = "Antigua and Barbuda"
    CASE "AI": r = "Anguilla"
    CASE "AL": r = "Albania"
    CASE "AM": r = "Armenia"
    CASE "AN": r = "Netherlands Antilles"
    CASE "AO": r = "Angola"
    CASE "AQ": r = "Antarctica"
    CASE "AR": r = "Argentina"
    CASE "AS": r = "American Samoa"
    CASE "AT": r = "Austria"
    CASE "AU": r = "Australia"
    CASE "AW": r = "Aruba"
    CASE "AX": r = "Aland Islands"
    CASE "AZ": r = "Azerbaijan"
    CASE "BA": r = "Bosnia Herzegovina"
    CASE "BB": r = "Barbados"
    CASE "BD": r = "Bangladesh"
    CASE "BE": r = "Belgium"
    CASE "BF": r = "Burkina Faso"
    CASE "BG": r = "Bulgaria"
    CASE "BH": r = "Bahrain"
    CASE "BI": r = "Burundi"
    CASE "BJ": r = "Benin"
    CASE "BM": r = "Bermuda"
    CASE "BN": r = "Brunei"
    CASE "BO": r = "Bolivia"
    CASE "BR": r = "Brazil"
    CASE "BS": r = "Bahamas"
    CASE "BT": r = "Bhutan"
    CASE "BV": r = "Bouvet Island"
    CASE "BW": r = "Botswana"
    CASE "BY": r = "Belarus"
    CASE "BZ": r = "Belize"
    CASE "CA": r = "Canada"
    CASE "CC": r = "Cocos-Keeling Islands"
    CASE "CD": r = "Democratic Republic of the Congo"
    CASE "CF": r = "Central African Republic"
    CASE "CG": r = "Congo"
    CASE "CH": r = "Switzerland"
    CASE "CI": r = "Ivory Coast"
    CASE "CK": r = "Cook Islands"
    CASE "CL": r = "Chile"
    CASE "CM": r = "Cameroon"
    CASE "CN": r = "China"
    CASE "CO": r = "Colombia"
    CASE "CR": r = "Costa Rica"
    CASE "CS": r = "Serbia-Montenegro"
    CASE "CU": r = "Cuba"
    CASE "CV": r = "Cape Verde"
    CASE "CX": r = "Christmas Island"
    CASE "CY": r = "Cyprus"
    CASE "CZ": r = "Czech Republic"
    CASE "DE": r = "Germany"
    CASE "DJ": r = "Djibouti"
    CASE "DK": r = "Denmark"
    CASE "DM": r = "Dominica"
    CASE "DO": r = "Dominican Republic"
    CASE "DZ": r = "Algeria"
    CASE "EC": r = "Ecuador"
    CASE "EE": r = "Estonia"
    CASE "EG": r = "Egypt"
    CASE "EH": r = "Western Sahara"
    CASE "ER": r = "Eritrea"
    CASE "ES": r = "Spain"
    CASE "ET": r = "Ethiopia"
    CASE "FI": r = "Finland"
    CASE "FJ": r = "Fiji"
    CASE "FK": r = "Falkland Islands"
    CASE "FM": r = "Micronesia"
    CASE "FO": r = "Faroe Islands"
    CASE "FR": r = "France"
    CASE "FX": r = "France"
    CASE "GA": r = "Gabon"
    CASE "GB": r = "Great Britain (UK)"
    CASE "GD": r = "Grenada"
    CASE "GE": r = "Georgia"
    CASE "GF": r = "French Guiana"
    CASE "GH": r = "Ghana"
    CASE "GI": r = "Gibraltar"
    CASE "GL": r = "Greenland"
    CASE "GM": r = "Gambia"
    CASE "GN": r = "Guinea"
    CASE "GP": r = "Guadeloupe"
    CASE "GQ": r = "Equatorial Guinea"
    CASE "GR": r = "Greece"
    CASE "GS": r = "S. Georgia and S. Sandwich Islands"
    CASE "GT": r = "Guatemala"
    CASE "GU": r = "Guam"
    CASE "GW": r = "Guinea-Bissau"
    CASE "GY": r = "Guyana"
    CASE "HK": r = "Hong Kong"
    CASE "HM": r = "Heard Island and McDonald Islands"
    CASE "HN": r = "Honduras"
    CASE "HR": r = "Croatia"
    CASE "HT": r = "Haiti"
    CASE "HU": r = "Hungary"
    CASE "ID": r = "Indonesia"
    CASE "IE": r = "Ireland"
    CASE "IL": r = "Israel"
    CASE "IN": r = "India"
    CASE "IO": r = "British Indian Ocean Territory"
    CASE "IQ": r = "Iraq"
    CASE "IR": r = "Iran"
    CASE "IS": r = "Iceland"
    CASE "IT": r = "Italy"
    CASE "JM": r = "Jamaica"
    CASE "JO": r = "Jordan"
    CASE "JP": r = "Japan"
    CASE "KE": r = "Kenya"
    CASE "KG": r = "Kyrgyzstan"
    CASE "KH": r = "Cambodia"
    CASE "KI": r = "Kiribati"
    CASE "KM": r = "Comoros"
    CASE "KN": r = "St Kitts and Nevis"
    CASE "KP": r = "North Korea"
    CASE "KR": r = "South Korea"
    CASE "KW": r = "Kuwait"
    CASE "KY": r = "Cayman Islands"
    CASE "KZ": r = "Kazakhstan"
    CASE "LA": r = "Laos"
    CASE "LB": r = "Lebanon"
    CASE "LC": r = "Saint Lucia"
    CASE "LI": r = "Liechtenstein"
    CASE "LK": r = "Sri Lanka"
    CASE "LR": r = "Liberia"
    CASE "LS": r = "Lesotho"
    CASE "LT": r = "Lithuania"
    CASE "LU": r = "Luxembourg"
    CASE "LV": r = "Latvia"
    CASE "LY": r = "Libya"
    CASE "MA": r = "Morocco"
    CASE "MC": r = "Monaco"
    CASE "MD": r = "Moldova"
    CASE "MG": r = "Madagascar"
    CASE "MH": r = "Marshall Islands"
    CASE "MK": r = "Macedonia"
    CASE "ML": r = "Mali"
    CASE "MM": r = "Myanmar"
    CASE "MN": r = "Mongolia"
    CASE "MO": r = "Macao"
    CASE "MP": r = "Northern Mariana Islands"
    CASE "MQ": r = "Martinique"
    CASE "MR": r = "Mauritania"
    CASE "MS": r = "Montserrat"
    CASE "MT": r = "Malta"
    CASE "MU": r = "Mauritius"
    CASE "MV": r = "Maldives"
    CASE "MW": r = "Malawi"
    CASE "MX": r = "Mexico"
    CASE "MY": r = "Malaysia"
    CASE "MZ": r = "Mozambique"
    CASE "NA": r = "Namibia"
    CASE "NC": r = "New Caledonia"
    CASE "NE": r = "Niger"
    CASE "NF": r = "Norfolk Island"
    CASE "NG": r = "Nigeria"
    CASE "NI": r = "Nicaragua"
    CASE "NL": r = "Netherlands"
    CASE "NO": r = "Norway"
    CASE "NP": r = "Nepal"
    CASE "NR": r = "Nauru"
    CASE "NU": r = "Niue"
    CASE "NZ": r = "New Zealand"
    CASE "OM": r = "Oman"
    CASE "PA": r = "Panama"
    CASE "PE": r = "Peru"
    CASE "PF": r = "French Polynesia"
    CASE "PG": r = "Papua New Guinea"
    CASE "PH": r = "Philippines"
    CASE "PK": r = "Pakistan"
    CASE "PL": r = "Poland"
    CASE "PM": r = "Saint Pierre and Miquelon"
    CASE "PN": r = "Pitcairn"
    CASE "PR": r = "Puerto Rico"
    CASE "PS": r = "Palestine"
    CASE "PT": r = "Portugal"
    CASE "PW": r = "Palau"
    CASE "PY": r = "Paraguay"
    CASE "QA": r = "Qatar"
    CASE "RE": r = "Reunion"
    CASE "RO": r = "Romania"
    CASE "RU": r = "Russia"
    CASE "RW": r = "Rwanda"
    CASE "SA": r = "Saudi Arabia"
    CASE "SB": r = "Solomon Islands"
    CASE "SC": r = "Seychelles"
    CASE "SD": r = "Sudan"
    CASE "SE": r = "Sweden"
    CASE "SG": r = "Singapore"
    CASE "SH": r = "Saint Helena"
    CASE "SI": r = "Slovenia"
    CASE "SJ": r = "Svalbard and Jan Mayen"
    CASE "SK": r = "Slovakia"
    CASE "SL": r = "Sierra Leone"
    CASE "SM": r = "San Marino"
    CASE "SN": r = "Senegal"
    CASE "SO": r = "Somalia"
    CASE "SR": r = "Suriname"
    CASE "ST": r = "Sao Tome and Principe"
    CASE "SU": r = "Russia"
    CASE "SV": r = "El Salvador"
    CASE "SY": r = "Syria"
    CASE "SZ": r = "Swaziland"
    CASE "TC": r = "Turks and Caicos Islands"
    CASE "TD": r = "Chad"
    CASE "TF": r = "French Southern Territories"
    CASE "TG": r = "Togo"
    CASE "TH": r = "Thailand"
    CASE "TJ": r = "Tajikistan"
    CASE "TK": r = "Tokelau"
    CASE "TL": r = "Timor-Leste"
    CASE "TM": r = "Turkmenistan"
    CASE "TN": r = "Tunisia"
    CASE "TO": r = "Tonga"
    CASE "TP": r = "East Timor"
    CASE "TR": r = "Turkey"
    CASE "TT": r = "Trinidad and Tobago"
    CASE "TV": r = "Tuvalu"
    CASE "TW": r = "Taiwan"
    CASE "TZ": r = "Tanzania"
    CASE "UA": r = "Ukraine"
    CASE "UG": r = "Uganda"
    CASE "UK": r = "United Kingdom"
    CASE "UM": r = "USA Minor Islands"
    CASE "US": r = "USA"
    CASE "UY": r = "Uruguay"
    CASE "UZ": r = "Uzbekistan"
    CASE "VA": r = "Vatican City State"
    CASE "VC": r = "Saint Vincent - Grenadines"
    CASE "VE": r = "Venezuela"
    CASE "VG": r = "Virgin Islands (British)"
    CASE "VI": r = "Virgin Islands (US)"
    CASE "VN": r = "Viet Nam"
    CASE "VU": r = "Vanuatu"
    CASE "WF": r = "Wallis and Futuna"
    CASE "WS": r = "Samoa"
    CASE "YE": r = "Yemen"
    CASE "YT": r = "Mayotte"
    CASE "YU": r = "Yugoslavia"
    CASE "ZA": r = "South Africa"
    CASE "ZM": r = "Zambia"
    CASE "ZR": r = "Zaire"
    CASE "ZW": r = "Zimbabwe"
    CASE "BIZ": r = "Business"
    CASE "COM": r = "Commercial"
    CASE "EDU": r = "US Educational"
    CASE "GOV": r = "US Government"
    CASE "INT": r = "International"
    CASE "MIL": r = "US Military"
    CASE "NET": r = "Network"
    CASE "ORG": r = "Nonprofit Organization"
    CASE "PRO": r = "Professional Services"
    CASE "AERO": r = "Aeronautic"
    CASE "ARPA": r = "Arpanet Technical Infrastructure"
    CASE "COOP": r = "Cooperative"
    CASE "INFO": r = "Info Domain"
    CASE "NAME": r = "Personal Name"
    CASE "NATO": r = "North Atlantic Treaty Organization"
    CASE ELSE: r = "<unknown>"
    END SELECT
    FUNCTION = r
    END FUNCTION
    Last edited by Wayne Diamond; 1 Aug 2009, 08:02 AM.
    -
Working...
X