Address Formatting for International Mailing? 84
linuxbaby asks: "Anyone have any advice or wisdom from experience about address formatting for international shipping? I'm starting to doubt the process of asking individual questions of 'name, company, address, city, state, postalcode, country' because of complaints or misunderstandings from places like Ireland (no postalcodes), Germany (postalcode goes before city), Japan and England (many lines of address info needed). Maybe the best approach is to just get the country as a option-select list of 2-character country codes, but leave the other lines wide open ('address1', 'address2', 'address3', 'address4') for the person to fill in as they see fit. The point here is not data mining, but shipping packages as accurately as possible, anywhere in the world. Thoughts?"
Effective Addressing for International Mail (Score:5, Informative)
Freeform! (Score:4, Informative)
What's wrong with just letting the user enter the address in a freeform text field? The user probably knows what his own address is, and can write it in a form that the local post office can deliver to. Just include a dropdown box for the country, and that should be all there's to it.
google for prior art (Score:2, Informative)
There's an example of what looks like a good solution used at https://www.theperlreview.com/cgi-bin/subscribe.c
They make some fields required (name and country would make sense) and others (such as state) are marked "required for some countries", with a big freeform text area marked "Mailing label" with the text "International subscribers: You can tell us what your mailing label should be, following your country's address format".
This seems a fair way of doing so, and that which fails your parser's ability to determine (ie, countries for which you don't know the convention) can be checked manually, with an additional contact-the-customer-and-verify step if you are really unsure.
As you contact customers and learn more about their specific formatting needs, update your parser -- use it to check the freeform address format, and perhaps warn the user if it doesn't seem to be valid (but allow them to continue anyways).
Universal Postal Union (Score:5, Informative)
Also, this looks interesting: International Address Standard UPU S42-1 [coverpages.org]
(BTW, I know nothing about this stuff, but I found it via Wikipedia, which these days is proving itself more useful than Google.)
But zip is a "checksum" they should check! (Score:3, Informative)
Zip codes, in countries that use them, are checksums. You need them in a separate field because you should check with the post office of that country to make sure it matches with the city. If the zip code and city/state do not match up you should make me verify the address. If the two match up odds are the address is good enough to get things to the right person.
If you can get someone's mail to the right zip code the post office doesn't really need the rest of the address, just the name. (Though it is much easier to deal with full addresses, so only try this when other options fail) This doesn't work so well if you name is common, but if you name is slightly obscure (which is most names, since obscure only means nobody else in town shares it) you are probably the only one in town with that name, and they can figure out where you live.
In short, the name and street address are checksums to each other, the local post office will notice a mismatch and try to correct them if they can. City/state, and zip are checksums to each other, and you should check them to be sure you get to the right town.
Now of course each country is different, but for most there is some variation of the above that you should use to verify the address is likely to be correct.
Of course checksum isn't the right term. There is math involved. However the concept is the same.
They Know Best, Not Your Database (Score:5, Informative)
I think frankly your best bet here is to be freeform. They know best how their addresses are written. So long as the country goes last, to get the parcel from your country out to the appropriate country, the rest of the address should be written to their custom so that their postal service will be most likely to deliver it.
I've seen all the things you describe - stuff like "90167 Bucharest" where the postcode precedes the city - and you're just not going to cope with all that if you try and enforce a complex system of validation.
Our database just has Address1-Address5 (use as many or as few as you want), Postcode (this can be blank), Country (this can't be).
When we tried entering a lot of addresses into the address book software of a certain well-known courier company, we ran into all sorts of problems. It would keep insisting on postcodes where they weren't appropriate, and so on. It's just more hassle than it's worth, and creates more problems (with literally not being able to enter what you know is correct) than it solves (stopping accidental bad data entry).
Re:Effective Addressing for International Mail (Score:4, Informative)
Re:ZIP codes (Score:2, Informative)
There is a limited character set : Not all letters are valid in all positions (C, I, K, M, O, V, are not valid in the last two characters), the last three characters are ALWAYS in the form digit letter letter, a UK postcode ALWAYS begins with at least one letter, and ALWAYS contains at least two digits. The recommended layout is to put a space before the last three characters.
[A-Z]{1,2}\d[A-Z\d]? \d[ABD-HJLNP-UW-Z]{2}
Within the UK, most sensible address forms will ask for a postcode and a building number or name, and look up on a database sold by Royal Mail (known as PAF, or Postal Address File).
The Netherlands postcode scheme is really much more clever. It includes check digit algorithms that will tell you if the building number should be odd, even, neither, either)