Address formats
Posted on 18 Jun 2009 at 11:48
Simon Jones tackles the tricky subject of handling addresses in applications, both within the UK and far beyond.
This month, I've been battling with the validation and formatting of street addresses. A customer of ours runs a business that deals with people in the UK and around the world, and this firm needs to capture addresses and send letters to all those people. While it's tempting just to provide users of your software with a single large box into which they can type the recipient's address, doing it this way is to throw away much information that would have been invaluable for sorting and selecting people based on their location. Say you wanted to invite all the people you know in Manchester to a seminar - if all your address data was entered via that single field then you'd have difficulty separating people who live in Manchester city in the UK from those who live at Manchester Road, Southport and those who live in Manchester, New Hampshire, USA; a simple text search wouldn't distinguish between these. You could search for people with a postcode in their address field, in which the postcode is an "M" followed by one or two digits, but that might also erroneously take in residents of the Isle of Man whose postcodes start "IM" followed by one or two digits, or indeed those around Romford, Essex where the postcodes start "RM". The fact is that despite the extra difficulty it imposes on the programmers, and the extra discipline on the users, it's better to separate every address into distinct fields at entry stage.
A UK postal address should consist of three parts: a postcode, a post town and everything else is the street address. The Royal Mail doesn't want you to put the county name in a postal address, because there are far too many instances where the street address lies in one county but the post town is in another. For instance, large parts of Wales have their post sorted and delivered from across the border in England, so postcodes that start "SY" are centred on Shrewsbury but may cover Shropshire, Cheshire, Dyfed and Powys.
Elsewhere in the world, the different national postal authorities have different rules as to what's desirable in an address. In the US, for example, they like to have the state name abbreviation as well as the "city" and "ZIP code" just to check that they're delivering to the right place. (One of the reasons The Simpsons were situated in "Springfield" is that more than half of US states have a town of that name.) Some countries that consist of several islands, such as New Zealand and Japan, want the name of the town and the island as well as the country. Other countries have deeper subdivisions such as France's Départements, Germany's Lande and many countries' districts. The names of such subdivisions vary and sometimes need to be included in the address and sometimes excluded, so if you're building a system that will work for worldwide addresses, you need to capture: Street address; Post town/City; County/State/D???©partement/Lande/Island/District or whatever; Postcode/ZIP code/Postal zone; Country. The street address may span multiple lines, whereas all the other items are single lines.
Each national postal authority lays out rules as to how addresses should be formatted to aid delivery of post, and all these rules are gathered together by the Universal Postal Union (UPU) - part of the United Nations - which acts as the forum for cooperation between national postal services. UPU publishes these rules on its website at www.pcpro/links/177advoff. On that website you can look up a country and see how it would like addresses to be presented. Some countries offer only a small example, leaving you to guess which lines of the example correspond with which parts of the address, while others specify that there must be no more than N lines in an address, that it must be right-aligned, that the font must be monospaced and between X and Y points.
Simon Jones
Simon is a contributing editor to PC Pro. He's an independent IT consultant specialising in Microsoft Office, Visual Basic and SQL Server.
advertisement
- The bulletproof Dell that costs an arm and a leg
- Microsoft Office 2010 Technical Preview: Q&A
- Lawnmowers, the TyTN II and one odd insurance request
- There'll never be a bulletproof OS
- How far can we trust apps?
- Five nice touches in Outlook 2010
- Building a better Google
- Beware HP's horrendous printer-driver glitch
- Microsoft debuts free Morro antivirus package
- Getting started with Search Server 2008 Express
- Motorola pays Lucas for its Droid
- Where are the killer apps for Windows?
- Will you hit the Orange iPhone "unlimited" cap?
- USB 3 first benchmark - it's here, and it's fast
- Why Windows 7 has forced me to worry about security
- How Dixons is (under)selling Windows 7
- Do I like Windows 7 because it's so like a Mac?
- No Windows 7 drivers turn Dell M1330 into a doorstop
- Is Windows 7 good looking enough to sway an Apple fan?
- Typekit brings print-like typography to the web
- Web censorship "breaches WTO rules"
- Facebook users to join the IM crowd
- Government promises broadband windfall for Scots
- Kingston bringing films to a flash drive near you
- Scientists tout cloaking tool for search engines
- Six-pack of fixes set for Patch Tuesday
- British Legion calls for Twitter silence on Poppy Day
- Spotify stems interest in illegal downloads
- Postal strike leads businesses to online alternatives
- Microsoft wants to expand Yahoo deal worldwide
advertisement

Printed from www.pcpro.co.uk

