Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: country codes

  1. #1
    Senior Member
    Join Date
    Nov 2001

    country codes

    while rummaging threw samespades file's i came accross a list of country codes. hmm! this could be usefull! so i reduced it to two fields added some crap and made it a perl script. if any one else has use for it the .pl is below and a version made executable with perl2exe is attached for anyone that wants fast access to country codes to see where something it coming from, but doesn't want to install perl. or take the time to look it up. i know it could use some work, like makeing any letter input into lower case, error handeling and removing a period if one is inputed but i dont feel like messing with it anymore the drudge work is done for you. if anyone does improve upon it feel free to post it (please)
    usage "country <two (or 3 or 4) letter code>"
    use strict;
    my %table;
    my $Ccode = $ARGV[0];

    my %table;
    $table{'ad'} = 'Andorra';
    $table{'ae'} = 'United Arab Emirates';
    $table{'af'} = 'Afghanistan';
    $table{'ag'} = 'Antiguaand Barbuda';
    $table{'ai'} = 'Anguilla';
    $table{'al'} = 'Albania';
    $table{'am'} = 'Armenia';
    $table{'an'} = 'Netherlands Antilles';
    $table{'ao'} = 'Angola';
    $table{'aq'} = 'Antarctica';
    $table{'ar'} = 'Argentina';
    $table{'arpa'} = 'Old style Arpanet';
    $table{'as'} = 'American Samoa';
    $table{'at'} = 'Austria';
    $table{'au'} = 'Australia';
    $table{'aw'} = 'Aruba';
    $table{'az'} = 'Azerbaidjan';
    $table{'ba'} = 'Bosnia-Herzegovina';
    $table{'bb'} = 'Barbados';
    $table{'bd'} = 'Bangladesh';
    $table{'be'} = 'Belgium';
    $table{'bf'} = 'BurkinaFaso';
    $table{'bg'} = 'Bulgaria';
    $table{'bh'} = 'Bahrain';
    $table{'bi'} = 'Burundi';
    $table{'bj'} = 'Benin';
    $table{'bm'} = 'Bermuda';
    $table{'bn'} = 'Brunei Darussalam';
    $table{'bo'} = 'Bolivia';
    $table{'br'} = 'Brazil';
    $table{'bs'} = 'Bahamas';
    $table{'bt'} = 'Bhutan';
    $table{'bv'} = 'Bouvet Island';
    $table{'bw'} = 'Botswana';
    $table{'by'} = 'Belarus';
    $table{'bz'} = 'Belize';
    $table{'ca'} = 'Canada';
    $table{'cc'} = 'Cocos Islands';
    $table{'cd'} = 'Republic of Congo';
    $table{'cf'} = 'Central African Republic';
    $table{'cg'} = 'Congo';
    $table{'ch'} = 'Switzerland';
    $table{'ci'} = 'Ivory Coast';
    $table{'ck'} = 'Cook Islands';
    $table{'cl'} = 'Chile';
    $table{'cm'} = 'Cameroon';
    $table{'cn'} = 'China';
    $table{'co'} = 'Colombia';
    $table{'com'} = 'USA International Commercial';
    $table{'cr'} = 'CostaRica';
    $table{'cs'} = 'FormerCzechoslovakia';
    $table{'cu'} = 'Cuba';
    $table{'cv'} = 'CapeVerde';
    $table{'cx'} = 'ChristmasIsland';
    $table{'cy'} = 'Cyprus';
    $table{'cz'} = 'CzechRepublic';
    $table{'de'} = 'Germany';
    $table{'dj'} = 'Djibouti';
    $table{'dk'} = 'Denmark';
    $table{'dm'} = 'Dominica';
    $table{'do'} = 'Dominican Republic';
    $table{'dz'} = 'Algeria';
    $table{'ec'} = 'Ecuador';
    $table{'edu'} = 'USA Educational';
    $table{'ee'} = 'Estonia';
    $table{'eg'} = 'Egypt';
    $table{'eh'} = 'Western Sahara';
    $table{'er'} = 'Eritrea';
    $table{'es'} = 'Spain';
    $table{'et'} = 'Ethiopia';
    $table{'fi'} = 'Finland';
    $table{'fj'} = 'Fiji';
    $table{'fk'} = 'FalklandIslands';
    $table{'fm'} = 'Micronesia';
    $table{'fo'} = 'FaroeIslands';
    $table{'fr'} = 'France';
    $table{'fx'} = 'France European Territory';
    $table{'ga'} = 'Gabon';
    $table{'gb'} = 'Great Britain';
    $table{'gd'} = 'Grenada';
    $table{'ge'} = 'Georgia';
    $table{'gf'} = 'French Guyana';
    $table{'gh'} = 'Ghana';
    $table{'gi'} = 'Gibraltar';
    $table{'gl'} = 'Greenland';
    $table{'gm'} = 'Gambia';
    $table{'gn'} = 'Guinea';
    $table{'gov'} = 'USA Federal Government';
    $table{'gp'} = 'Guadeloupe French';
    $table{'gq'} = 'Equatorial Guinea';
    $table{'gr'} = 'Greece';
    $table{'gs'} = 'S Georgia-S Sandwich Isls';
    $table{'gt'} = 'Guatemala';
    $table{'gu'} = 'Guam-USA';
    $table{'gw'} = 'Guinea Bissau';
    $table{'gy'} = 'Guyana';
    $table{'hk'} = 'HongKong';
    $table{'hm'} = 'Heard and McDonald Islands';
    $table{'hn'} = 'Honduras';
    $table{'hr'} = 'Croatia';
    $table{'ht'} = 'Haiti';
    $table{'hu'} = 'Hungary';
    $table{'id'} = 'Indonesia';
    $table{'ie'} = 'Ireland';
    $table{'il'} = 'Israel';
    $table{'im'} = 'Isle of Man UK';
    $table{'in'} = 'India';
    $table{'int'} = 'International';
    $table{'io'} = 'British Indian Ocean Territory';
    $table{'iq'} = 'Iraq';
    $table{'ir'} = 'Iran';
    $table{'is'} = 'Iceland';
    $table{'it'} = 'Italy';
    $table{'jm'} = 'Jamaica';
    $table{'jo'} = 'Jordan';
    $table{'jp'} = 'Japan';
    $table{'ke'} = 'Kenya';
    $table{'kg'} = 'Kyrgyz Republic';
    $table{'kh'} = 'Cambodia';
    $table{'ki'} = 'Kiribati';
    $table{'km'} = 'Comoros';
    $table{'kn'} = 'Saint Kitts and Nevis Anguilla';
    $table{'kp'} = 'North Korea';
    $table{'kr'} = 'South Korea';
    $table{'kw'} = 'Kuwait';
    $table{'ky'} = 'Cayman Islands';
    $table{'kz'} = 'Kazakhstan';
    $table{'la'} = 'Laos';
    $table{'lb'} = 'Lebanon';
    $table{'lc'} = 'SaintLucia';
    $table{'li'} = 'Liechtenstein';
    $table{'lk'} = 'SriLanka';
    $table{'lr'} = 'Liberia';
    $table{'ls'} = 'Lesotho';
    $table{'lt'} = 'Lithuania';
    $table{'lu'} = 'Luxembourg';
    $table{'lv'} = 'Latvia';
    $table{'ly'} = 'Libya';
    $table{'ma'} = 'Morocco';
    $table{'mc'} = 'Monaco';
    $table{'md'} = 'Moldavia';
    $table{'mg'} = 'Madagascar';
    $table{'mh'} = 'Marshall Islands';
    $table{'mil'} = 'USAMilitary';
    $table{'mk'} = 'Macedonia';
    $table{'ml'} = 'Mali';
    $table{'mm'} = 'Myanmar';
    $table{'mn'} = 'Mongolia';
    $table{'mo'} = 'Macau';
    $table{'mp'} = 'Northern Mariana Islands';
    $table{'mq'} = 'Martinique French';
    $table{'mr'} = 'Mauritania';
    $table{'ms'} = 'Montserrat';
    $table{'mt'} = 'Malta';
    $table{'mu'} = 'Mauritius';
    $table{'mv'} = 'Maldives';
    $table{'mw'} = 'Malawi';
    $table{'mx'} = 'Mexico';
    $table{'my'} = 'Malaysia';
    $table{'mz'} = 'Mozambique';
    $table{'na'} = 'Namibia';
    $table{'nato'} = 'NATO';
    $table{'nc'} = 'New Caledonia French';
    $table{'ne'} = 'Niger';
    $table{'net'} = 'Network services';
    $table{'nf'} = 'Norfolk Island';
    $table{'ng'} = 'Nigeria';
    $table{'ni'} = 'Nicaragua';
    $table{'nl'} = 'Netherlands';
    $table{'no'} = 'Norway';
    $table{'np'} = 'Nepal';
    $table{'nr'} = 'Nauru';
    $table{'nt'} = 'Neutral Zone';
    $table{'nu'} = 'Niue';
    $table{'nz'} = 'New Zealand';
    $table{'om'} = 'Oman';
    $table{'org'} = 'Non-Profit Organisations';
    $table{'pa'} = 'Panama';
    $table{'pe'} = 'Peru';
    $table{'pf'} = 'Polynesia French';
    $table{'pg'} = 'Papua New Guinea';
    $table{'ph'} = 'Philippines';
    $table{'pk'} = 'Pakistan';
    $table{'pl'} = 'Poland';
    $table{'pm'} = 'Saint Pierre and Miquelon';
    $table{'pn'} = 'Pitcairn Island';
    $table{'pr'} = 'Puerto Rico';
    $table{'pt'} = 'Portugal';
    $table{'pw'} = 'Palau';
    $table{'py'} = 'Paraguay';
    $table{'qa'} = 'Qatar';
    $table{'re'} = 'Reunion French';
    $table{'ro'} = 'Romania';
    $table{'ru'} = 'Russian Federation';
    $table{'rw'} = 'Rwanda';
    $table{'sa'} = 'SaudiArabia';
    $table{'sb'} = 'Solomon Islands';
    $table{'sc'} = 'Seychelles';
    $table{'sd'} = 'Sudan';
    $table{'se'} = 'Sweden';
    $table{'sg'} = 'Singapore';
    $table{'sh'} = 'Saint Helena';
    $table{'si'} = 'Slovenia';
    $table{'sj'} = 'Svalbard and Jan Mayen Islands';
    $table{'sk'} = 'Slovak Republic';
    $table{'sl'} = 'Sierra Leone';
    $table{'sm'} = 'San Marino';
    $table{'sn'} = 'Senegal';
    $table{'so'} = 'Somalia';
    $table{'sr'} = 'Suriname';
    $table{'st'} = 'Saint Tomeand Principe';
    $table{'su'} = 'Former USSR';
    $table{'sv'} = 'ElSalvador';
    $table{'sy'} = 'Syria';
    $table{'sz'} = 'Swaziland';
    $table{'tc'} = 'Turks and CaicosIs lands';
    $table{'td'} = 'Chad';
    $table{'tf'} = 'French Southern Territories';
    $table{'tg'} = 'Togo';
    $table{'th'} = 'Thailand';
    $table{'tj'} = 'Tajikistan';
    $table{'tk'} = 'Tokelau';
    $table{'tm'} = 'Turkmenistan';
    $table{'tn'} = 'Tunisia';
    $table{'to'} = 'Tonga';
    $table{'tp'} = 'East Timor';
    $table{'tr'} = 'Turkey';
    $table{'tt'} = 'Trinidad Tobago';
    $table{'tv'} = 'Tuvalu';
    $table{'tw'} = 'Taiwan';
    $table{'tz'} = 'Tanzania';
    $table{'ua'} = 'Ukraine';
    $table{'ug'} = 'Uganda';
    $table{'uk'} = 'United Kingdom';
    $table{'govuk'} = 'United Kingdom';
    $table{'acuk'} = 'United Kingdom';
    $table{'um'} = 'USA Minor Out lying Islands';
    $table{'us'} = 'United States';
    $table{'uucp'} = 'UUCP pseudo domain';
    $table{'uy'} = 'Uruguay';
    $table{'uz'} = 'Uzbekistan';
    $table{'va'} = 'Vatican City State';
    $table{'vc'} = 'Saint Vincent Grenadines';
    $table{'ve'} = 'Venezuela';
    $table{'vg'} = 'Virgin Islands British';
    $table{'vi'} = 'Virgin Islands USA';
    $table{'vn'} = 'Vietnam';
    $table{'vu'} = 'Vanuatu';
    $table{'wf'} = 'Wallis and Futuna Islands';
    $table{'ws'} = 'Samoa';
    $table{'ye'} = 'Yemen';
    $table{'yt'} = 'Mayotte';
    $table{'yu'} = 'Yugoslavia';
    $table{'coza'} = 'South Africa';
    $table{'orgza'} = 'South Africa';
    $table{'zm'} = 'Zambia';
    $table{'zr'} = 'Zaire';
    $table{'zw'} = 'Zimbabwe';

    print "\n\n\n\n\n\n\n\n\n\n $Ccode is $table{$Ccode}!\n\n\n";
    print "\n\n\n\n Press Enter to Close\n\n\n ";

    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Wow this is impressive! Thank you for the work

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Nice work man! pretty simple, but could be quite usefull.

  4. #4
    Join Date
    Apr 2004
    Nice man, but how did you get the info to make this script?
    I am the uber duck!!1
    Proxy Tools

  5. #5
    Senior Member
    Join Date
    Feb 2004
    Nice man, but how did you get the info to make this script?
    while rummaging threw samespades file's i came accross a list of country codes
    Hmmm... I wonder...

    Or even if he hadn't said that, I would have assumed he would have Googled and got this page.

    Anyways nice code Tedob. Odd, and a little random, but still pretty cool.

  6. #6
    Join Date
    Apr 2004
    1,066 ? I'm just wondering but, does that count as part of sam spade's files?
    I am the uber duck!!1
    Proxy Tools

  7. #7
    Just Another Geek
    Join Date
    Jul 2002
    Rotterdam, Netherlands
    Just a perl thingy

    Why didn't you initialise %table like this:

    my(%table)= ( 'ad' => 'Andorra', 'ae' => 'United Arab Emirates', 'af' => 'Afghanistan' etc..);
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  8. #8
    Senior Member
    Join Date
    Nov 2001
    SirDice it was easier to do it this way!

    using the for command to extract/add data:
    echo $table{'%d'} = '%f';
    or whatever the token where i dont really remember off the top of my head but you get the idea

    actually i made it about two week ago and didn't know if it would be usfull or not but last night i wanted to look up a country code and i remembered...Ahh! so i figured it could be somewhat usefull and posted it.

  9. #9
    Senior Member
    Join Date
    Nov 2001
    Kind of a terribly ineffecient way of going about things given there is already a country code conversion class that comes with perl. Locale::Country already has this functionality, but in addition, it also supplies reverse functionality (country name -> code mapping), as well as arrays of all the codes.

    Here's an example app I whipped up in a couple minutes:
    use strict;
    use Locale::Country;
    my ($code, $country);
    $code = $ARGV[0];
    if (length($code) < 1) {
      print "Please supply a country code.\n";
    $country = code2country($code);
    if (defined $country) {
      print "Code '$code' is $country\n";
    } else {
      print "'$code' is not a valid country code!\n";
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  10. #10
    Senior Member
    Join Date
    Sep 2001
    you could just as easily open a txt file with 2 fields, and search for the tld you want..

    Yes hashes are awsome, but loading that many fields, JUST to do 1 lookup? .. you could have written a perl grep that was was more efficient.

    and i do wonder how this could possibly be a security discussion.. Unless running that script on a slow machine might DoS it...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts