Saturday, January 24, 2009

Callsign prefix to country mapping

A while back I wrote an article about automated recognition of nominally valid callsigns using a relatively simple regular expression (which I didn't happen to mention in the article).  I've since expanded on this.

Using the ITU's Table of Allocation of International Call Sign Series, I've built a simple table that maps the first two characters of a putative callsign into the country with authority over that callsign. You should first verify that the putative callsign is valid by verifying that it matches one of these two regular expressions: ^[BFGIKMNTW][0-9][A-Z0-9]{0,3}[A-Z]$ or ^[A-Z0-9][A-Z0-9][0-9][A-Z0-9]{0,3}[A-Z]$.

Click here to download this table, in tab-delimited format. There are no column headers. The second column is the ISO 3166 2-letter code for the country. I've arbitrarily used codes X1 for the ICAO and X2 for the World Meterological Organization, since these entities have no ISO codes (not that either of them issues amateur radio licenses, as far as I know).  This table is explicitly designed to be used as a lookup against the first two characters of a string.

As an aside, I'd have preferred to use the ISO three-letter codes, but ISO doesn't make those freely available. A source that does seem to have three-letter (as well as ISO 3166 numeric codes) is http://www.davros.org/misc/iso3166.html, but of course I have no idea of the validity or recentness of this source. Use at your own risk.