mirror of https://github.com/kiwix/libkiwix.git
+ fix kiwix:ucFirst and kiwix:lcFirst
This commit is contained in:
parent
835388daf9
commit
2ad238f095
|
@ -174,36 +174,36 @@ std::string kiwix::ucFirst (const std::string &word) {
|
||||||
if (word.empty())
|
if (word.empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string ucFirstWord;
|
std::string result;
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ucFirstWord = word;
|
result = word;
|
||||||
ucFirstWord[0] = toupper(ucFirstWord[0]);
|
result[0] = toupper(result[0]);
|
||||||
#else
|
#else
|
||||||
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
UnicodeString unicodeWord(word.c_str());
|
||||||
UnicodeString ucFirstLetter = firstLetter.toUpper();
|
UnicodeString unicodeFirstLetter = unicodeWord.tempSubString(0, 1).toUpper();
|
||||||
ucFirstLetter.toUTF8String(ucFirstWord);
|
unicodeWord.replace(0, 1, unicodeFirstLetter);
|
||||||
ucFirstWord += word.substr(1);
|
unicodeWord.toUTF8String(result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ucFirstWord;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string kiwix::lcFirst (const std::string &word) {
|
std::string kiwix::lcFirst (const std::string &word) {
|
||||||
if (word.empty())
|
if (word.empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string ucFirstWord;
|
std::string result;
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
ucFirstWord = word;
|
result = word;
|
||||||
ucFirstWord[0] = tolower(ucFirstWord[0]);
|
result[0] = tolower(result[0]);
|
||||||
#else
|
#else
|
||||||
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
UnicodeString unicodeWord(word.c_str());
|
||||||
UnicodeString ucFirstLetter = firstLetter.toLower();
|
UnicodeString unicodeFirstLetter = unicodeWord.tempSubString(0, 1).toLower();
|
||||||
ucFirstLetter.toUTF8String(ucFirstWord);
|
unicodeWord.replace(0, 1, unicodeFirstLetter);
|
||||||
ucFirstWord += word.substr(1);
|
unicodeWord.toUTF8String(result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ucFirstWord;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue