I have to perform mapping between ISO 3166-1 alpha-3 and IOC country codes.

It looks like there is no way to do this natively via .NET framework. But could be that I'm missing something.

Most likely I would need to create some dictionary to perform this mapping. Does anybody know some library/open-source project/xml feed/etc where I can find this mappings handy?

有帮助吗?

解决方案

Wikipedia also provides comparison table. You can easily convert this data into whatever format you want, considering it have stable format and is easily parsed.

其他提示

I parsed wiki page and generated dictionary, which only contains data for mismatching pairs. For all other countries 3-letter code should be the same.

Here is source code (given "as-is"):

    // Defines mapping between ISO 3166-1 alpha-3 and Olympic IOC country codes
    // Only mismatches are defined
    // Taken from here: http://en.wikipedia.org/wiki/Comparison_of_IOC,_FIFA,_and_ISO_3166_country_codes    
    var dictionary = new Dictionary<string, string>();
    dictionary.Add("DZA", "ALG");
    dictionary.Add("ASM", "ASA");
    dictionary.Add("AGO", "ANG");
    dictionary.Add("ATG", "ANT");
    dictionary.Add("ABW", "ARU");
    dictionary.Add("BHS", "BAH");
    dictionary.Add("BHR", "BRN");
    dictionary.Add("BGD", "BAN");
    dictionary.Add("BRB", "BAR");
    dictionary.Add("BLZ", "BIZ");
    dictionary.Add("BMU", "BER");
    dictionary.Add("BTN", "BHU");
    dictionary.Add("BWA", "BOT");
    dictionary.Add("VGB", "IVB");
    dictionary.Add("BRN", "BRU");
    dictionary.Add("BGR", "BUL");
    dictionary.Add("BFA", "BUR");
    dictionary.Add("KHM", "CAM");
    dictionary.Add("CYM", "CAY");
    dictionary.Add("TCD", "CHA");
    dictionary.Add("CHL", "CHI");
    dictionary.Add("COG", "CGO");
    dictionary.Add("CRI", "CRC");
    dictionary.Add("HRV", "CRO");
    dictionary.Add("DNK", "DEN");
    dictionary.Add("SLV", "ESA");
    dictionary.Add("GNQ", "GEQ");
    dictionary.Add("FJI", "FIJ");
    dictionary.Add("GMB", "GAM");
    dictionary.Add("DEU", "GER");
    dictionary.Add("GRC", "GRE");
    dictionary.Add("GRD", "GRN");
    dictionary.Add("GTM", "GUA");
    dictionary.Add("GIN", "GUI");
    dictionary.Add("GNB", "GBS");
    dictionary.Add("HTI", "HAI");
    dictionary.Add("HND", "HON");
    dictionary.Add("IDN", "INA");
    dictionary.Add("IRN", "IRI");
    dictionary.Add("KWT", "KUW");
    dictionary.Add("LVA", "LAT");
    dictionary.Add("LBN", "LIB");
    dictionary.Add("LSO", "LES");
    dictionary.Add("LBY", "LBA");
    dictionary.Add("MDG", "MAD");
    dictionary.Add("MWI", "MAW");
    dictionary.Add("MYS", "MAS");
    dictionary.Add("MRT", "MTN");
    dictionary.Add("MUS", "MRI");
    dictionary.Add("MCO", "MON");
    dictionary.Add("MNG", "MGL");
    dictionary.Add("MMR", "MYA");
    dictionary.Add("NPL", "NEP");
    dictionary.Add("NLD", "NED");
    dictionary.Add("NIC", "NCA");
    dictionary.Add("NER", "NIG");
    dictionary.Add("NGA", "NGR");
    dictionary.Add("OMN", "OMA");
    dictionary.Add("PSE", "PLE");
    dictionary.Add("PRY", "PAR");
    dictionary.Add("PHL", "PHI");
    dictionary.Add("PRT", "POR");
    dictionary.Add("PRI", "PUR");
    dictionary.Add("KNA", "SKN");
    dictionary.Add("VCT", "VIN");
    dictionary.Add("WSM", "SAM");
    dictionary.Add("SAU", "KSA");
    dictionary.Add("SYC", "SEY");
    dictionary.Add("SGP", "SIN");
    dictionary.Add("SVN", "SLO");
    dictionary.Add("SLB", "SOL");
    dictionary.Add("ZAF", "RSA");
    dictionary.Add("LKA", "SRI");
    dictionary.Add("SDN", "SUD");
    dictionary.Add("CHE", "SUI");
    dictionary.Add("TWN", "TPE");
    dictionary.Add("TZA", "TAN");
    dictionary.Add("TGO", "TOG");
    dictionary.Add("TON", "TGA");
    dictionary.Add("TTO", "TRI");
    dictionary.Add("ARE", "UAE");
    dictionary.Add("VIR", "ISV");
    dictionary.Add("URY", "URU");
    dictionary.Add("VUT", "VAN");
    dictionary.Add("VNM", "VIE");
    dictionary.Add("ZMB", "ZAM");
    dictionary.Add("ZWE", "ZIM");

I don't know if one exists but it wouldn't be hard to create by just parsing the tables in your two links and matching up by country name. I bet that would get you 95%, while the rest could be done manually.

I would bet you'll spend more time trying to find a pre-built one versus building it yourself.

php Array with 3 letter ISO country codes

$Countries=array();

array_push($Countries,"ABW");
array_push($Countries,"AFG");
array_push($Countries,"AGO");
array_push($Countries,"AIA");
array_push($Countries,"ALA");
array_push($Countries,"ALB");
array_push($Countries,"AND");
array_push($Countries,"ARE");
array_push($Countries,"ARG");
array_push($Countries,"ARM");
array_push($Countries,"ASM");
array_push($Countries,"ATA");
array_push($Countries,"ATF");
array_push($Countries,"ATG");
array_push($Countries,"AUS");
array_push($Countries,"AUT");
array_push($Countries,"AZE");
array_push($Countries,"BDI");
array_push($Countries,"BEL");
array_push($Countries,"BEN");
array_push($Countries,"BES");
array_push($Countries,"BFA");
array_push($Countries,"BGD");
array_push($Countries,"BGR");
array_push($Countries,"BHR");
array_push($Countries,"BHS");
array_push($Countries,"BIH");
array_push($Countries,"BLM");
array_push($Countries,"BLR");
array_push($Countries,"BLZ");
array_push($Countries,"BMU");
array_push($Countries,"BOL");
array_push($Countries,"BRA");
array_push($Countries,"BRB");
array_push($Countries,"BRN");
array_push($Countries,"BTN");
array_push($Countries,"BVT");
array_push($Countries,"BWA");
array_push($Countries,"CAF");
array_push($Countries,"CAN");
array_push($Countries,"CCK");
array_push($Countries,"CHE");
array_push($Countries,"CHL");
array_push($Countries,"CHN");
array_push($Countries,"CIV");
array_push($Countries,"CMR");
array_push($Countries,"COD");
array_push($Countries,"COG");
array_push($Countries,"COK");
array_push($Countries,"COL");
array_push($Countries,"COM");
array_push($Countries,"CPV");
array_push($Countries,"CRI");
array_push($Countries,"CUB");
array_push($Countries,"CUW");
array_push($Countries,"CXR");
array_push($Countries,"CYM");
array_push($Countries,"CYP");
array_push($Countries,"CZE");
array_push($Countries,"DEU");
array_push($Countries,"DJI");
array_push($Countries,"DMA");
array_push($Countries,"DNK");
array_push($Countries,"DOM");
array_push($Countries,"DZA");
array_push($Countries,"ECU");
array_push($Countries,"EGY");
array_push($Countries,"ERI");
array_push($Countries,"ESH");
array_push($Countries,"ESP");
array_push($Countries,"EST");
array_push($Countries,"ETH");
array_push($Countries,"FIN");
array_push($Countries,"FJI");
array_push($Countries,"FLK");
array_push($Countries,"FRA");
array_push($Countries,"FRO");
array_push($Countries,"FSM");
array_push($Countries,"GAB");
array_push($Countries,"GBR");
array_push($Countries,"GEO");
array_push($Countries,"GGY");
array_push($Countries,"GHA");
array_push($Countries,"GIB");
array_push($Countries,"GIN");
array_push($Countries,"GLP");
array_push($Countries,"GMB");
array_push($Countries,"GNB");
array_push($Countries,"GNQ");
array_push($Countries,"GRC");
array_push($Countries,"GRD");
array_push($Countries,"GRL");
array_push($Countries,"GTM");
array_push($Countries,"GUF");
array_push($Countries,"GUM");
array_push($Countries,"GUY");
array_push($Countries,"HKG");
array_push($Countries,"HMD");
array_push($Countries,"HND");
array_push($Countries,"HRV");
array_push($Countries,"HTI");
array_push($Countries,"HUN");
array_push($Countries,"IDN");
array_push($Countries,"IMN");
array_push($Countries,"IND");
array_push($Countries,"IOT");
array_push($Countries,"IRL");
array_push($Countries,"IRN");
array_push($Countries,"IRQ");
array_push($Countries,"ISL");
array_push($Countries,"ISR");
array_push($Countries,"ITA");
array_push($Countries,"JAM");
array_push($Countries,"JEY");
array_push($Countries,"JOR");
array_push($Countries,"JPN");
array_push($Countries,"KAZ");
array_push($Countries,"KEN");
array_push($Countries,"KGZ");
array_push($Countries,"KHM");
array_push($Countries,"KIR");
array_push($Countries,"KNA");
array_push($Countries,"KOR");
array_push($Countries,"KWT");
array_push($Countries,"LAO");
array_push($Countries,"LBN");
array_push($Countries,"LBR");
array_push($Countries,"LBY");
array_push($Countries,"LCA");
array_push($Countries,"LIE");
array_push($Countries,"LKA");
array_push($Countries,"LSO");
array_push($Countries,"LTU");
array_push($Countries,"LUX");
array_push($Countries,"LVA");
array_push($Countries,"MAC");
array_push($Countries,"MAF");
array_push($Countries,"MAR");
array_push($Countries,"MCO");
array_push($Countries,"MDA");
array_push($Countries,"MDG");
array_push($Countries,"MDV");
array_push($Countries,"MEX");
array_push($Countries,"MHL");
array_push($Countries,"MKD");
array_push($Countries,"MLI");
array_push($Countries,"MLT");
array_push($Countries,"MMR");
array_push($Countries,"MNE");
array_push($Countries,"MNG");
array_push($Countries,"MNP");
array_push($Countries,"MOZ");
array_push($Countries,"MRT");
array_push($Countries,"MSR");
array_push($Countries,"MTQ");
array_push($Countries,"MUS");
array_push($Countries,"MWI");
array_push($Countries,"MYS");
array_push($Countries,"MYT");
array_push($Countries,"NAM");
array_push($Countries,"NCL");
array_push($Countries,"NER");
array_push($Countries,"NFK");
array_push($Countries,"NGA");
array_push($Countries,"NIC");
array_push($Countries,"NIU");
array_push($Countries,"NLD");
array_push($Countries,"NOR");
array_push($Countries,"NPL");
array_push($Countries,"NRU");
array_push($Countries,"NZL");
array_push($Countries,"OMN");
array_push($Countries,"PAK");
array_push($Countries,"PAN");
array_push($Countries,"PCN");
array_push($Countries,"PER");
array_push($Countries,"PHL");
array_push($Countries,"PLW");
array_push($Countries,"PNG");
array_push($Countries,"POL");
array_push($Countries,"PRI");
array_push($Countries,"PRK");
array_push($Countries,"PRT");
array_push($Countries,"PRY");
array_push($Countries,"PSE");
array_push($Countries,"PYF");
array_push($Countries,"QAT");
array_push($Countries,"REU");
array_push($Countries,"ROU");
array_push($Countries,"RUS");
array_push($Countries,"RWA");
array_push($Countries,"SAU");
array_push($Countries,"SDN");
array_push($Countries,"SEN");
array_push($Countries,"SGP");
array_push($Countries,"SGS");
array_push($Countries,"SHN");
array_push($Countries,"SJM");
array_push($Countries,"SLB");
array_push($Countries,"SLE");
array_push($Countries,"SLV");
array_push($Countries,"SMR");
array_push($Countries,"SOM");
array_push($Countries,"SPM");
array_push($Countries,"SRB");
array_push($Countries,"SSD");
array_push($Countries,"STP");
array_push($Countries,"SUR");
array_push($Countries,"SVK");
array_push($Countries,"SVN");
array_push($Countries,"SWE");
array_push($Countries,"SWZ");
array_push($Countries,"SXM");
array_push($Countries,"SYC");
array_push($Countries,"SYR");
array_push($Countries,"TCA");
array_push($Countries,"TCD");
array_push($Countries,"TGO");
array_push($Countries,"THA");
array_push($Countries,"TJK");
array_push($Countries,"TKL");
array_push($Countries,"TKM");
array_push($Countries,"TLS");
array_push($Countries,"TON");
array_push($Countries,"TTO");
array_push($Countries,"TUN");
array_push($Countries,"TUR");
array_push($Countries,"TUV");
array_push($Countries,"TWN");
array_push($Countries,"TZA");
array_push($Countries,"UGA");
array_push($Countries,"UKR");
array_push($Countries,"UMI");
array_push($Countries,"URY");
array_push($Countries,"USA");
array_push($Countries,"UZB");
array_push($Countries,"VAT");
array_push($Countries,"VCT");
array_push($Countries,"VEN");
array_push($Countries,"VGB");
array_push($Countries,"VIR");
array_push($Countries,"VNM");
array_push($Countries,"VUT");
array_push($Countries,"WLF");
array_push($Countries,"WSM");
array_push($Countries,"YEM");
array_push($Countries,"ZAF");
array_push($Countries,"ZMB");
array_push($Countries,"ZWE");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top