Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-11-06 10:21:41 +0300
committerAlex Zolotarev <alex@maps.me>2015-11-10 19:16:05 +0300
commit30d1880a6fe5f15add03a59cfa04411bdfda1d36 (patch)
treea1fd0c0867f7ecdade742fb5599187fb8acd0781 /generator/osm2meta.hpp
parent7685f5327b54902e09d9caf12ad288439510af45 (diff)
Fixed wikipedia links mwm storage and displaying in Android.
Previous solution was a really bad engineering decision (more details in https://github.com/mapsme/omim/pull/421 )
Diffstat (limited to 'generator/osm2meta.hpp')
-rw-r--r--generator/osm2meta.hpp48
1 files changed, 1 insertions, 47 deletions
diff --git a/generator/osm2meta.hpp b/generator/osm2meta.hpp
index 4b30411912..79efd40fb9 100644
--- a/generator/osm2meta.hpp
+++ b/generator/osm2meta.hpp
@@ -213,51 +213,5 @@ protected:
{
return v;
}
-
- // Special URL encoding for wikipedia:
- // Replaces special characters with %HH codes
- // And spaces with underscores.
- string WikiUrlEncode(string const & value) const
- {
- ostringstream escaped;
- escaped.fill('0');
- escaped << hex;
-
- for (auto const & c : value)
- {
- if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
- escaped << c;
- else if (c == ' ')
- escaped << '_';
- else
- escaped << '%' << std::uppercase << setw(2) << static_cast<int>(static_cast<unsigned char>(c));
- }
-
- return escaped.str();
- }
-
- string ValidateAndFormat_wikipedia(string const & v) const
- {
- // Find prefix before ':', shortest case: "lg:aa".
- string::size_type i = v.find(':');
- if (i == string::npos || i < 2 || i + 2 > v.length())
- return string();
-
- // URL encode lang:title (lang is at most 3 chars), so URL can be reconstructed faster.
- if (i <= 3 || v.substr(0, i) == "be-x-old")
- return v.substr(0, i + 1) + WikiUrlEncode(v.substr(i + 1));
-
- static string::size_type const minUrlPartLength = string("//be.wikipedia.org/wiki/AB").length();
- if (v[i+1] == '/' && i + minUrlPartLength < v.length())
- {
- // Convert URL to "lang:title".
- i += 3; // skip "://"
- string::size_type const j = v.find('.', i + 1);
- static string const wikiUrlPart = ".wikipedia.org/wiki/";
- if (j != string::npos && v.substr(j, wikiUrlPart.length()) == wikiUrlPart)
- return v.substr(i, j - i) + ":" + v.substr(j + wikiUrlPart.length());
- }
- return string();
- }
-
+ string ValidateAndFormat_wikipedia(string v) const;
};