From 034cf3cfe474ba2478bec43f529a69dd86da511e Mon Sep 17 00:00:00 2001 From: upstream svn Date: Thu, 22 Dec 2011 21:41:01 +0000 Subject: [PATCH] Fixed country flags for Turkish localization See http://forum.amule.org/index.php?topic=19398.0 --- .svn-revision | 2 +- docs/Changelog | 1 + src/IP2Country.cpp | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.svn-revision b/.svn-revision index fee4e09f..1c1fbaa2 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10696 +10697 diff --git a/docs/Changelog b/docs/Changelog index c819da47..c6ccab96 100644 --- a/docs/Changelog +++ b/docs/Changelog @@ -11,6 +11,7 @@ Version 2.4.0 - The river knows. * Backtrace (crash or assertion) is written to logfile * Fix: disabling protocol obfuscation broke Kad and triggered assertions * Fixed "Prompt on exit" preference + * Fixed country flags for Turkish localization -------------------------------------------------------------------------------- diff --git a/src/IP2Country.cpp b/src/IP2Country.cpp index 59139c9e..e8e26c24 100644 --- a/src/IP2Country.cpp +++ b/src/IP2Country.cpp @@ -163,7 +163,7 @@ void CIP2Country::LoadFlags() // Load data from xpm files for (int i = 0; i < flags::FLAGS_XPM_SIZE; ++i) { CountryData countrydata; - countrydata.Name = char2unicode(flags::flagXPMCodeVector[i].code); + countrydata.Name = wxString(flags::flagXPMCodeVector[i].code, wxConvISO8859_1); countrydata.Flag = wxImage(flags::flagXPMCodeVector[i].xpm); if (countrydata.Flag.IsOk()) { @@ -193,7 +193,18 @@ const CountryData& CIP2Country::GetCountryData(const wxString &ip) return it->second; } - const wxString CCode = wxString(char2unicode(GeoIP_country_code_by_addr(m_geoip, unicode2char(ip)))).MakeLower(); + // wxString::MakeLower() fails miserably in Turkish localization with their dotted/non-dotted 'i's + // So fall back to some good ole C string processing. + std::string strCode; + const char * c = GeoIP_country_code_by_addr(m_geoip, unicode2char(ip)); + if (!c) { + c = "unknown"; + } + for ( ; *c; c++) { + strCode += ((*c >= 'A' && *c <= 'Z') ? *c + 'a' - 'A' : *c); + } + + const wxString CCode(strCode.c_str(), wxConvISO8859_1); CountryDataMap::iterator it = m_CountryDataMap.find(CCode); if (it == m_CountryDataMap.end()) { -- 2.11.4.GIT