[search] Fixed bug with non-working degrees matching due to unicode normalization

This commit is contained in:
Alex Zolotarev 2014-03-31 18:48:59 +03:00 committed by Alex Zolotarev
parent 6bba16f8a5
commit c61c5f7521
2 changed files with 12 additions and 0 deletions

View file

@ -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;

View file

@ -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°4520.9916S, 37°373.6228W", lat, lon), ());
TEST_ALMOST_EQUAL(lat, -55.755831, ());
TEST_ALMOST_EQUAL(lon, -37.617673, ());
TEST(MatchLatLonDegree("W55°4520.9916″, S37°373.6228″", lat, lon), ());
TEST_ALMOST_EQUAL(lon, -55.755831, ());
TEST_ALMOST_EQUAL(lat, -37.617673, ());