Feb 6th 2014, 17:14:32
They aren't duplicate names.
What happens is an old trick. When you enter a country name, the game removes punctuation marks (basically it only accepts alphabets, numbers and single spaces between words). Unfortunately, the multiple spaces between words are replaced with a single space before the removal of punctuation marks.
In the following examples, I will use <space> to denote 1 space (the character typed by the spacebar)
Example 1:
Country name is "Abcd<space>defg".
This name is valid.
Example 2:
Country name is "Abcd<space><space>defg".
This name contains 2 spaces in a row, it is shortened to the country name in Example 1, and will complain about the country name already being taken.
Example 3:
Country name is "Abcd.defg".
This country name contains a fullstop and is removed. The resulting country name is "Abcddefg".
Example 4:
Country name is "Abcd.<space>defg".
This country name contains a fullstop and is removed. The resulting country name is "Abcd<space>defg", which is already taken by Example 1.
Example 5:
Country name is "Abcd<space>.<space>defg".
This country name doesn't contain more than 1 space next to each other and passes this check.
This country name is then found to contain a fullstop and is removed.
The resulting country name is "Abcd<space><space>defg", and the country is created, because it is different from the country in Example 1.
What happens in Example 5 is that in ALL browsers, under the HTML webpage specifications, when DISPLAYING text that contains multiple contiguous whitespace, all that whitespace is reduced to a single space. If you were to check the HTML received by the browser, you would see that the country in Example 1 will be "Abcd<space>defg" while the one in Example 5 will be "Abcd<space><space>defg". But both country names are DISPLAYED identically due to how HTML/CSS works.
Specifically, "Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default." There are ways to change the default, or change it for a specific piece of text to be displayed, but this has to be specified in HTML/CSS.
Edit: To fix the problem, the code should remove punctuation, then collapse sequences of whitespace into a single whitespace, instead of doing this in the reverse order.