1

I was wondering, are there many variations that postal codes can take around the world?

For example, in Switzerland, every zip code is a four-digit number, but it can be written as XXXX or CH-XXXX.

I would basically like to have a function that makes a postal code canonical, given the country. For example f(XXXX, Switzerland) == f(CH-XXXX, Switzerland) == CH-XXXX.

  • It's unlikely that there are more than 2500 variations on postal codes around the world (less than 10 per country, on average). Attempts to enforce global canonical addressing will likely prove challenging. – Vince Jul 13 '15 at 14:54
  • @Vince just to clarify, I don't want the output of the function to be globally unique. I just want all variants within a country to map to same canonical value. What do you mean by 2500 variations? – mitchus Jul 13 '15 at 15:19
  • Standardizing postal code by country will not be easy, even in the developed world (e.g., the US has zip codes and zip+4, but not at 100% coverage); in the developing world, the differences between urban and rural addressing are likely to be significant. – Vince Jul 13 '15 at 16:28
5

All of the world's postal code formats are tabulated here: http://www.grcdi.nl/gsb/world%20postal%20code%20formats.html

Some countries may precede their postal codes with a country code, as you describe in your question; and where codes contain spaces or punctuation they may be found written without, but even then there are only a few hundred possible formats in total. I have 295 variations in my files.

-2

I make this server that provides all spain postal codes.

https://github.com/OussamaAlouat/postal-codes-backend

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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