I did this years ago and I just looked to see if I could find the code and I must have just let it rot (entropy takes over the bits and turns them into ordered chess openings).
However, my method was not fool proof because there are exceptions to the basic rules that everyone knows. For example, I ran across a special event station in Russia or Finland (can't remember which) that failed my call sign test because it was too long at about 10 characters. I had a sanity check on the length of I think around 8 characters. I fixed my sanity check.
My method is straight-forward:
- US calls were easy even though there are some to watch out for such as KG4 prefix is something other than a southern state (if I remember correctly, this was years ago).
- I downloaded the ARRL list of official country or DX-Entity call sign prefixes and turn it into a database used by my call sign lookup.
- My program (since I am US resident) always checked US call sign first but as a cheat I also had the US Call sign database in a fast lookup table (all memory resident).
- Then, I would do a RE prefix check on the ARRL DX-entity list and usually that creates a match to ID the country or entity name (not all entries are countries).
- If I miss on the program, I make note of it in a log and go check on it later to see why. Usually it is a weird case that snuck thru or maybe a special event station call sign.
To test my program when I first ran it, I downloaded the entire QRZ.com database (I was a subscriber with permission to download) and I tested my program against every single call sign in the QRZ database to validate that we had the same DX entity name. I actually found a few that were incorrect in the QRZ database.
I wrote the program in C++ and it ran on my Mac computer and I stopped using it back around 2005 when I started using the MacLoggerDX application which had its own call sign handler.