From c61c5f7521345bac99b8117762ed5f47b7b72816 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Mon, 31 Mar 2014 18:48:59 +0300 Subject: [PATCH] [search] Fixed bug with non-working degrees matching due to unicode normalization --- search/latlon_match.cpp | 7 +++++++ search/search_tests/latlon_match_test.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/search/latlon_match.cpp b/search/latlon_match.cpp index 3c510adec9..4e970423a5 100644 --- a/search/latlon_match.cpp +++ b/search/latlon_match.cpp @@ -109,6 +109,13 @@ int Match2Bytes(char const * & s) case 0x9D: // ” return 2; case 0xB2: // ′ + if (static_cast(*s) == 0xE2 + && static_cast(*(s+1)) == 0x80 + && static_cast(*(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; diff --git a/search/search_tests/latlon_match_test.cpp b/search/search_tests/latlon_match_test.cpp index 9d81387db8..848eef6491 100644 --- a/search/search_tests/latlon_match_test.cpp +++ b/search/search_tests/latlon_match_test.cpp @@ -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, ());