![]() |
IOC-Code 2 Nationname und zurück
Hallo Wissende,
hat von Euch eventuell einer schon eine Unit fertig, die aus GER => Germany oder => Deutschland macht und das Ganze mit allen offiziellen IOC´s und Ländernamen (sprich von ANG bis ZIM)? Wie man das in einer Klasse verpackt wäre mir schon klar, aber wenn´s schon jemand erledigt hat, würde ich mir diese Fleissarbeit gern sparen. |
AW: IOC-Code 2 Nationname und zurück
IOC-Code? Nie gehört. Meinst du vielleicht die dreibuchstabige Version von
![]() |
AW: IOC-Code 2 Nationname und zurück
|
AW: IOC-Code 2 Nationname und zurück
Liste der Anhänge anzeigen (Anzahl: 1)
Guten Abend,
![]() Das ganze in eine Unit zu kapseln (hard codiert) halte ich nicht unbedingt für eine anstrebenswerte Lösung. Aus meiner Sicht zu unflexibel. Eine Datei die eingelesen werden kann, kann sehr viel leichter angepasst werden. Denn es gibt auch Änderungen (wenn auch wenige) bei den Kürzeln. Grüße Klaus |
AW: IOC-Code 2 Nationname und zurück
Als Ressource in die EXE gelinkt, läßt sie sich später auch noch leicht erweitern.
> Beim nächsten Kompilieren und notfalls auch über einen Ressourceneditor. |
AW: IOC-Code 2 Nationname und zurück
Vielleicht hilft es zu etwas (auch wenn ISO, nicht IOC):
![]() Die haben auch einen Webservice zum Daten abrufen (praktisch für ein Update). |
AW: IOC-Code 2 Nationname und zurück
Jo, danke für das Feedback. Ich habe mich gestern mal hingesetzt und eine Function zusammengezimmert, wenngleich mich das mit der RES-Datei auch sehr interessieren würde.
Hier mal der Code. Achtung, da sind auch ein paar IOC´s drin, die NICHT offiziel sind, aber von dem ein oder anderen Sportverband intern noch so benutzt werden. Wenn´s mans besser oder einfacher machen könnte, wäre ich über ein Feedback dankbar. Ich würde die Klasse eigentlich gern noch mit den ISO´s und den deutschen Ländernamen erweitern.
Delphi-Quellcode:
function GetCountryNameByIOCCode(IocCode : String) : String;
begin Result := ''; if IocCode = 'AFG' then Result :='Afghanistan'; if IocCode = 'AHO' then Result :='Netherlands Antilles'; if IocCode = 'ALB' then Result :='Albania'; if IocCode = 'ALG' then Result :='Algeria'; if IocCode = 'AND' then Result :='Andorra'; if IocCode = 'ANG' then Result :='Angola'; if IocCode = 'ANT' then Result :='Antigua and Barbuda'; if IocCode = 'ARG' then Result :='Argentina'; if IocCode = 'ARM' then Result :='Armenia'; if IocCode = 'ARU' then Result :='Aruba'; if IocCode = 'ASA' then Result :='American Samoa'; if IocCode = 'AUS' then Result :='Australia'; if IocCode = 'AUT' then Result :='Austria'; if IocCode = 'AZE' then Result :='Azerbaijan'; if IocCode = 'BAH' then Result :='Bahamas'; if IocCode = 'BAN' then Result :='Bangladesh'; if IocCode = 'BAR' then Result :='Barbados'; if IocCode = 'BDI' then Result :='Burundi'; if IocCode = 'BEL' then Result :='Belgium'; if IocCode = 'BEN' then Result :='Benin'; if IocCode = 'BER' then Result :='Bermuda'; if IocCode = 'BHU' then Result :='Bhutan'; if IocCode = 'BIH' then Result :='Bosnia and Herzegovina'; if IocCode = 'BIZ' then Result :='Belize'; if IocCode = 'BLR' then Result :='Belarus'; if IocCode = 'BOL' then Result :='Bolivia'; if IocCode = 'BOT' then Result :='Botswana'; if IocCode = 'BRA' then Result :='Brazil'; if IocCode = 'BRN' then Result :='Bahrain'; if IocCode = 'BRU' then Result :='Brunei'; if IocCode = 'BUL' then Result :='Bulgaria'; if IocCode = 'BUR' then Result :='Burkina Faso'; if IocCode = 'CAF' then Result :='Central African Republic'; if IocCode = 'CAM' then Result :='Cambodia'; if IocCode = 'CAN' then Result :='Canada'; if IocCode = 'CAY' then Result :='Cayman Islands'; if IocCode = 'CGO' then Result :='Congo'; if IocCode = 'CHA' then Result :='Chad'; if IocCode = 'CHI' then Result :='Chile'; if IocCode = 'CHN' then Result :='China'; if IocCode = 'CIV' then Result :='Côte d''Ivoire'; if IocCode = 'CMR' then Result :='Cameroon'; if IocCode = 'COD' then Result :='DR Congo'; if IocCode = 'COK' then Result :='Cook Islands'; if IocCode = 'COL' then Result :='Colombia'; if IocCode = 'COM' then Result :='Comoros'; if IocCode = 'CPV' then Result :='Cape Verde'; if IocCode = 'CRC' then Result :='Costa Rica'; if IocCode = 'CRO' then Result :='Croatia'; if IocCode = 'CUB' then Result :='Cuba'; if IocCode = 'CYP' then Result :='Cyprus'; if IocCode = 'CZE' then Result :='Czech Republic'; if IocCode = 'DEN' then Result :='Denmark'; if IocCode = 'DJI' then Result :='Djibouti'; if IocCode = 'DMA' then Result :='Dominica'; if IocCode = 'DOM' then Result :='Dominican Republic'; if IocCode = 'ECU' then Result :='Ecuador'; if IocCode = 'EGY' then Result :='Egypt'; if IocCode = 'ENG' then Result :='England'; if IocCode = 'ERI' then Result :='Eritrea'; if IocCode = 'ESA' then Result :='El Salvador'; if IocCode = 'ESP' then Result :='Spain'; if IocCode = 'EST' then Result :='Estonia'; if IocCode = 'ETH' then Result :='Ethiopia'; if IocCode = 'FIJ' then Result :='Fiji'; if IocCode = 'FIN' then Result :='Finland'; if IocCode = 'FRA' then Result :='France'; if IocCode = 'FSM' then Result :='Micronesia'; if IocCode = 'GAB' then Result :='Gabon'; if IocCode = 'GAM' then Result :='Gambia'; if IocCode = 'GBR' then Result :='Great Britain'; if IocCode = 'GBS' then Result :='Guinea-Bissau'; if IocCode = 'GEO' then Result :='Georgia'; if IocCode = 'GEQ' then Result :='Equatorial Guinea'; if IocCode = 'GER' then Result :='Germany'; if IocCode = 'GHA' then Result :='Ghana'; if IocCode = 'GRE' then Result :='Greece'; if IocCode = 'GRN' then Result :='Grenada'; if IocCode = 'GUA' then Result :='Guatemala'; if IocCode = 'GUI' then Result :='Guinea'; if IocCode = 'GUM' then Result :='Guam'; if IocCode = 'GUY' then Result :='Guyana'; if IocCode = 'HAI' then Result :='Haiti'; if IocCode = 'HKG' then Result :='Hong Kong'; if IocCode = 'HON' then Result :='Honduras'; if IocCode = 'HUN' then Result :='Hungary'; if IocCode = 'INA' then Result :='Indonesia'; if IocCode = 'IN' then Result :='India'; if IocCode = 'IND' then Result :='India'; if IocCode = 'IRI' then Result :='Iran'; if IocCode = 'IRL' then Result :='Ireland'; if IocCode = 'IRQ' then Result :='Iraq'; if IocCode = 'ISL' then Result :='Iceland'; if IocCode = 'ISR' then Result :='Israel'; if IocCode = 'ISV' then Result :='Virgin Islands'; if IocCode = 'ITA' then Result :='Italy'; if IocCode = 'IVB' then Result :='British Virgin Islands'; if IocCode = 'JAM' then Result :='Jamaica'; if IocCode = 'JOR' then Result :='Jordan'; if IocCode = 'JPN' then Result :='Japan'; if IocCode = 'KAZ' then Result :='Kazakhstan'; if IocCode = 'KEN' then Result :='Kenya'; if IocCode = 'KGZ' then Result :='Kyrgyzstan'; if IocCode = 'KIR' then Result :='Kiribati'; if IocCode = 'KOR' then Result :='South Korea'; if IocCode = 'KSA' then Result :='Saudi Arabia'; if IocCode = 'KUW' then Result :='Kuwait'; if IocCode = 'LAO' then Result :='Laos'; if IocCode = 'LAT' then Result :='Latvia'; if IocCode = 'LBA' then Result :='Libya'; if IocCode = 'LBR' then Result :='Liberia'; if IocCode = 'LCA' then Result :='Saint Lucia'; if IocCode = 'LES' then Result :='Lesotho'; if IocCode = 'LIB' then Result :='Lebanon'; if IocCode = 'LIE' then Result :='Liechtenstein'; if IocCode = 'LTU' then Result :='Lithuania'; if IocCode = 'LUX' then Result :='Luxembourg'; if IocCode = 'MAD' then Result :='Madagascar'; if IocCode = 'MAR' then Result :='Morocco'; if IocCode = 'MAS' then Result :='Malaysia'; if IocCode = 'MAW' then Result :='Malawi'; if IocCode = 'MDA' then Result :='Moldova'; if IocCode = 'MDV' then Result :='Maldives'; if IocCode = 'MEX' then Result :='Mexico'; if IocCode = 'MGL' then Result :='Mongolia'; if IocCode = 'MHL' then Result :='Marshall Islands'; if IocCode = 'MKD' then Result :='Macedonia'; if IocCode = 'MLI' then Result :='Mali'; if IocCode = 'MLT' then Result :='Malta'; if IocCode = 'MNE' then Result :='Montenegro'; if IocCode = 'MON' then Result :='Monaco'; if IocCode = 'MOZ' then Result :='Mozambique'; if IocCode = 'MRI' then Result :='Mauritius'; if IocCode = 'MTN' then Result :='Mauritania'; if IocCode = 'MYA' then Result :='Myanmar'; if IocCode = 'NAM' then Result :='Namibia'; if IocCode = 'NCA' then Result :='Nicaragua'; if IocCode = 'NL' then Result :='Netherlands'; if IocCode = 'NED' then Result :='Netherlands'; if IocCode = 'NEP' then Result :='Nepal'; if IocCode = 'NGR' then Result :='Nigeria'; if IocCode = 'NIG' then Result :='Niger'; if IocCode = 'NOR' then Result :='Norway'; if IocCode = 'NRU' then Result :='Nauru'; if IocCode = 'NZ' then Result :='New Zealand'; if IocCode = 'NZL' then Result :='New Zealand'; if IocCode = 'OMA' then Result :='Oman'; if IocCode = 'PAK' then Result :='Pakistan'; if IocCode = 'PAN' then Result :='Panama'; if IocCode = 'PAR' then Result :='Paraguay'; if IocCode = 'PER' then Result :='Peru'; if IocCode = 'PGL' then Result :='Portugal'; if IocCode = 'PHI' then Result :='Philippines'; if IocCode = 'PLE' then Result :='Palestine'; if IocCode = 'PLW' then Result :='Palau'; if IocCode = 'PNG' then Result :='Papua New Guinea'; if IocCode = 'POL' then Result :='Poland'; if IocCode = 'POR' then Result :='Portugal'; if IocCode = 'PRK' then Result :='North Korea'; if IocCode = 'PUR' then Result :='Puerto Rico'; if IocCode = 'QAT' then Result :='Qatar'; if IocCode = 'ROU' then Result :='Romania'; if IocCode = 'RSA' then Result :='South Africa'; if IocCode = 'RUS' then Result :='Russia'; if IocCode = 'RWA' then Result :='Rwanda'; if IocCode = 'SA' then Result :='South Africa'; if IocCode = 'SAM' then Result :='Samoa'; if IocCode = 'SCO' then Result :='Scotland'; if IocCode = 'SEN' then Result :='Senegal'; if IocCode = 'SEY' then Result :='Seychelles'; if IocCode = 'SIN' then Result :='Singapore'; if IocCode = 'SKN' then Result :='Saint Kitts and Nevis'; if IocCode = 'SLE' then Result :='Sierra Leone'; if IocCode = 'SLO' then Result :='Slovenia'; if IocCode = 'SMR' then Result :='San Marino'; if IocCode = 'SOL' then Result :='Solomon Islands'; if IocCode = 'SOM' then Result :='Somalia'; if IocCode = 'SRB' then Result :='Serbia'; if IocCode = 'SRI' then Result :='Sri Lanka'; if IocCode = 'STP' then Result :='São Tomé and Príncipe'; if IocCode = 'SUD' then Result :='Sudan'; if IocCode = 'SUI' then Result :='Switzerland'; if IocCode = 'SUR' then Result :='Suriname'; if IocCode = 'SVK' then Result :='Slovakia'; if IocCode = 'SWE' then Result :='Sweden'; if IocCode = 'SWI' then Result :='Switzerland'; if IocCode = 'SWZ' then Result :='Swaziland'; if IocCode = 'SYR' then Result :='Syria'; if IocCode = 'TAN' then Result :='Tanzania'; if IocCode = 'TGA' then Result :='Tonga'; if IocCode = 'THA' then Result :='Thailand'; if IocCode = 'TJK' then Result :='Tajikistan'; if IocCode = 'TKM' then Result :='Turkmenistan'; if IocCode = 'TLS' then Result :='Timor-Leste'; if IocCode = 'TOG' then Result :='Togo'; if IocCode = 'TPE' then Result :='Chinese Taipei'; if IocCode = 'TRI' then Result :='Trinidad and Tobago'; if IocCode = 'TUN' then Result :='Tunisia'; if IocCode = 'TUR' then Result :='Turkey'; if IocCode = 'TUV' then Result :='Tuvalu'; if IocCode = 'UAE' then Result :='United Arab Emirates'; if IocCode = 'UGA' then Result :='Uganda'; if IocCode = 'UK' then Result :='United Kingdom'; if IocCode = 'UKR' then Result :='Ukraine'; if IocCode = 'URU' then Result :='Uruguay'; if IocCode = 'USA' then Result :='United States'; if IocCode = 'UZB' then Result :='Uzbekistan'; if IocCode = 'VAN' then Result :='Vanuatu'; if IocCode = 'VEN' then Result :='Venezuela'; if IocCode = 'VIE' then Result :='Vietnam'; if IocCode = 'VIN' then Result :='Saint Vincent and the Grenadines'; if IocCode = 'WAL' then Result :='Wales'; if IocCode = 'YEM' then Result :='Yemen'; if IocCode = 'ZAM' then Result :='Zambia'; if IocCode = 'ZIM' then Result :='Zimbabwe'; end; |
AW: IOC-Code 2 Nationname und zurück
Ich würde das aber nicht fest codieren, sondern als Tabelle ( DB, XML, Ini, ...) ablegen; kann man später einfacher erweitern
|
AW: IOC-Code 2 Nationname und zurück
Zitat:
Und dann bei Zurückgeben einfach mit ner select den entsprechende Wert aus der Tabelle suchen. |
AW: IOC-Code 2 Nationname und zurück
Hi,
sollte man nicht nach einem match auch aus der Funktion rausspringen? Anderenfalls werden ja im Extremfall noch n-1 ifs verglichen, die alle nur noch false sein können? LG, Frederic |
AW: IOC-Code 2 Nationname und zurück
Zitat:
|
AW: IOC-Code 2 Nationname und zurück
Hi,
aber case geht doch nur bei Ordinaltypen, oder? LG, Frederic |
AW: IOC-Code 2 Nationname und zurück
Zitat:
Zurück in Delphi hast Recht. Am besten löst man die Aufgabe wie mkinzler schon gesagt mit ner DB oder XML Datei. Alles andere ist zu hartkodiert. |
AW: IOC-Code 2 Nationname und zurück
wie wäre es mit sowas
Delphi-Quellcode:
Gruß
function Uebersetzen(const inw:string[3]):string;
begin case longint(inw) of longint('ABC'):result:='abcdef' .. K-H |
AW: IOC-Code 2 Nationname und zurück
Delphi-Quellcode:
Der Grund ist, daß die ungenutzen Zeichen undefiniert und somit zufällig sind.
function Uebersetzen(const inw: String): String;
var S: String[3]; begin ZeroMemory(@S, SizeOf(S), 0); // s := #0#0#0; S := AnsiString(inv); case LongInt(S) of ... Womit die Integer nicht eindeutig sind, was schlecht ist, für den Vergleich. |
AW: IOC-Code 2 Nationname und zurück
Oder man nutzt die Funktion
Delphi-Quellcode:
. Damit kann man bequem ein case nutzen und das ganze ist auf Wunsch (IndexText <-> IndexStr) auch noch case-insensitive.
StrUtils.IndexText
Was die n-1 if's angeht: Würde bei sowas nicht die Compileroptimierung zuschlagen? Es dürfte imho durchaus erkennbar sein, dass im jeweiligen Scope nur ein Pfad erfolgreich ist und der Rest ignoriert werden kann. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:33 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz