GNOME Bugzilla – Bug 202133
Address entry via free-form text only works for US addresses
Last modified: 2004-04-15 16:17:37 UTC
The conversion of free-form addresses in the address text box to address fields (city, state, zip, etc) only works for US addresses. To reproduce: - New contact - In the address box, type 1 High Street London WC1 England - click "Address" button Actual result: <address> = "1 High Street", <address2> = " London WC1 United Kingdom" Expected result: <addess> = "1 High Street", <city> = "London", <ZIP code> = "WC1", <country> = "England"> (similar things happen with US addresses if you don't separate city and state with a comma). Here's a possible algorithm: - set <address> to the text in the first line - from bottom, find first line that contains any numbers (this contains a zip code) - the zip code is either the maximum trailing or the maximum leading string which contains any numbers (it's either "city state zip" or "city zip" or "state zip" or "zip city", possibly with commas somewhere). I believe even in UK/Canadian post codes each part contains at least one number, e.g, "WC1 1TN"). Note that you could have something like "D 57654 Berlin" (in which case "D 57654" is the ZIP, and something like "75004 Paris cedex 05" or "CZ-5432 Prague 8" (so numbers on both ends mean the initial part is the ZIP). So I suppose do this: From right, search for first all-alpha word. The part behind it is X. Then match all alpha-only words, that part is Y. The part remaining on the left is Z. If Z is empty, zip = X, continue processing Y; otherwise zip = Z, continue processing YX. - Y is either "city, state" or "city" or "state". So if there's a comma with strings not containing numbers on either side we know it's city and state. Otherwise: if there are two lines below, they are <state> and <country>. If there's only one line below, it could be either the state/province or the country. This obviously won't work for all cases, but would probably be better than what it does now. In particular, it will screw up in Canada, where you could have either one of the following: Montreal HF3 HT3 Quebec Montreal Quebec HF3 HT3 Montreal Quebec Canada HF3 HT3
Found a good reference webpage: http://www.columbia.edu/kermit/postal.html It shows that the issue is pretty complicated.
*** bug 200471 has been marked as a duplicate of this bug. ***
I apologize for the spam; re-setting all target milestones to 'future' in preparation for evolution 1.0. If you have any questions, please feel free to write louie@ximian.com.
i mark this as a part of meta bug 250483... *** This bug has been marked as a duplicate of 250483 ***