forked from organicmaps/organicmaps
[search] Fixed bug with non-working degrees matching due to unicode normalization
This commit is contained in:
parent
6bba16f8a5
commit
c61c5f7521
2 changed files with 12 additions and 0 deletions
|
@ -109,6 +109,13 @@ int Match2Bytes(char const * & s)
|
|||
case 0x9D: // ”
|
||||
return 2;
|
||||
case 0xB2: // ′
|
||||
if (static_cast<uint8_t>(*s) == 0xE2
|
||||
&& static_cast<uint8_t>(*(s+1)) == 0x80
|
||||
&& static_cast<uint8_t>(*(s+2)) == 0xB2)
|
||||
{
|
||||
s += 3;
|
||||
return 2; // this specific case when the string is normalized and ″ is splitted to ′′
|
||||
}
|
||||
return 1;
|
||||
case 0xB3: // ″
|
||||
return 2;
|
||||
|
|
|
@ -109,6 +109,11 @@ UNIT_TEST(LatLon_Degree_Match)
|
|||
TEST_ALMOST_EQUAL(lat, -55.755831, ());
|
||||
TEST_ALMOST_EQUAL(lon, -37.617673, ());
|
||||
|
||||
// We can receive already normalized string, and double quotes become two single quotes
|
||||
TEST(MatchLatLonDegree("55°45′20.9916′′S, 37°37′3.6228′′W", lat, lon), ());
|
||||
TEST_ALMOST_EQUAL(lat, -55.755831, ());
|
||||
TEST_ALMOST_EQUAL(lon, -37.617673, ());
|
||||
|
||||
TEST(MatchLatLonDegree("W55°45′20.9916″, S37°37′3.6228″", lat, lon), ());
|
||||
TEST_ALMOST_EQUAL(lon, -55.755831, ());
|
||||
TEST_ALMOST_EQUAL(lat, -37.617673, ());
|
||||
|
|
Loading…
Add table
Reference in a new issue