Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I need to encode data into a user token that describes the user's Country, State, and city. I understand that different descriptors apply to different government hierarchies, but am looking for a standard of some type that has already sorted this out.

What ISO standard, binary format, etc is best at describing a user who may be from any country?

share|improve this question
    
Similar, might help: stackoverflow.com/questions/4840928/… –  Silviu Burcea Feb 7 at 17:53
2  
There's en.wikipedia.org/wiki/ISO_3166 which might be of some use. It doesn't define an address format, but it includes standard country codes. –  FrustratedWithFormsDesigner Feb 7 at 17:54
1  
Latitude and longitude? –  Eric Feb 7 at 18:04

1 Answer 1

Bluntly, there isn't any one standard. Within the US, there are differing notations for states, counties, and regions (zip codes, area codes, metropolitan regions, etc.). While the US does have a standardized address format, even that is highly subject to variations. Also, address standards change regularly. Before the age of the internet, mailing a letter could be done without a zip code (because they hadn't been invented at the time) and you used a 3 letter abbreviation for most states.

Canada has a similar addressing scheme to the US. However, the postal codes in Canada are 6 or 7 digits. Including a space after the 3rd character of the postal code may appear to be the same region, but it isn't. I have also heard rumors of Canada moving to an 8 digit postal code.

Almost every country has an online guide from their official postal service with detailed information about acceptable address formats.

Google, ESRI, and other map data providers have come up with varying ways to associate an address with a lat/long pair. Google uses KML (a specific standard of XML used for addresses). They break an address into a street number, street name, lat/long, and several political hierarchies. You will find that in some countries, the political divisions can be 7 or 8 layers deep (maybe more since the last time I did research into this area).

If you are looking at what you need to store in a database for your customers, follow the US address format with several additional address lines (I typically store a minimum of 3 address lines for international addresses), a city, a state or province, a postal code (international needs to allow for at least 15 characters, digits and alpha), and a country. I have started to include lat/long recently as addresses can change without warning.

There are ISO standards for country code which a quick search will turn up a bunch of links. Beyond that, you are pretty much on your own for formatting though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.