diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index 6506807af..8a6ece163 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -516,6 +516,10 @@ namespace kiwix { myPrefix = kiwix::lcFirst(myPrefix); this->searchSuggestions(myPrefix, suggestionsCount, false); + /* Try with title words */ + myPrefix = kiwix::toTitle(myPrefix); + this->searchSuggestions(myPrefix, suggestionsCount, false); + return retVal; } diff --git a/src/common/stringTools.cpp b/src/common/stringTools.cpp index 6352d9e88..68527ad49 100644 --- a/src/common/stringTools.cpp +++ b/src/common/stringTools.cpp @@ -207,3 +207,21 @@ std::string kiwix::lcFirst (const std::string &word) { return result; } + + +std::string kiwix::toTitle (const std::string &word) { + if (word.empty()) + return ""; + + std::string result; + +#ifdef __ANDROID__ + result = word; +#else + UnicodeString unicodeWord(word.c_str()); + unicodeWord = unicodeWord.toTitle(0); + unicodeWord.toUTF8String(result); +#endif + + return result; +} diff --git a/src/common/stringTools.h b/src/common/stringTools.h index 47cbc6f9e..8993c65f5 100644 --- a/src/common/stringTools.h +++ b/src/common/stringTools.h @@ -58,6 +58,7 @@ namespace kiwix { std::string ucFirst(const std::string &word); std::string lcFirst(const std::string &word); + std::string toTitle(const std::string &word); } #endif