mirror of https://github.com/kiwix/libkiwix.git
+ fixes for Android
This commit is contained in:
parent
2a13f2a177
commit
5d8593805f
|
@ -48,30 +48,6 @@ std::string kiwix::removeAccents(const std::string &text) {
|
||||||
return unaccentedText;
|
return unaccentedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string kiwix::ucFirst (const std::string &word) {
|
|
||||||
if (word.empty())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
std::string ucFirstWord;
|
|
||||||
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
|
||||||
UnicodeString ucFirstLetter = firstLetter.toUpper();
|
|
||||||
ucFirstLetter.toUTF8String(ucFirstWord);
|
|
||||||
ucFirstWord += word.substr(1);
|
|
||||||
return ucFirstWord;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string kiwix::lcFirst (const std::string &word) {
|
|
||||||
if (word.empty())
|
|
||||||
return "";
|
|
||||||
|
|
||||||
std::string ucFirstWord;
|
|
||||||
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
|
||||||
UnicodeString ucFirstLetter = firstLetter.toLower();
|
|
||||||
ucFirstLetter.toUTF8String(ucFirstWord);
|
|
||||||
ucFirstWord += word.substr(1);
|
|
||||||
return ucFirstWord;
|
|
||||||
}
|
|
||||||
|
|
||||||
void kiwix::printStringInHexadecimal(UnicodeString s) {
|
void kiwix::printStringInHexadecimal(UnicodeString s) {
|
||||||
std::cout << std::showbase << std::hex;
|
std::cout << std::showbase << std::hex;
|
||||||
for (int i=0; i<s.length(); i++) {
|
for (int i=0; i<s.length(); i++) {
|
||||||
|
@ -147,7 +123,7 @@ std::string kiwix::urlEncode(const std::string &c) {
|
||||||
std::string kiwix::urlDecode(const std::string &SRC) {
|
std::string kiwix::urlDecode(const std::string &SRC) {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
char ch;
|
char ch;
|
||||||
int i, ii;
|
unsigned int i, ii;
|
||||||
for (i=0; i<SRC.length(); i++) {
|
for (i=0; i<SRC.length(); i++) {
|
||||||
if (int(SRC[i])==37) {
|
if (int(SRC[i])==37) {
|
||||||
sscanf(SRC.substr(i+1,2).c_str(), "%x", &ii);
|
sscanf(SRC.substr(i+1,2).c_str(), "%x", &ii);
|
||||||
|
@ -161,7 +137,7 @@ std::string kiwix::urlDecode(const std::string &SRC) {
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
/* Split string in a token array */
|
/* Split string in a token array */
|
||||||
std::vector<std::string> kiwix::split(const std::string & str,
|
std::vector<std::string> kiwix::split(const std::string & str,
|
||||||
|
@ -198,20 +174,36 @@ std::string kiwix::ucFirst (const std::string &word) {
|
||||||
if (word.empty())
|
if (word.empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string new_string = word;
|
std::string ucFirstWord;
|
||||||
new_string[0] = toupper(new_string[0]);
|
|
||||||
|
|
||||||
return new_string;
|
#ifdef __ANDROID__
|
||||||
|
ucFirstWord = word;
|
||||||
|
ucFirstWord[0] = toupper(ucFirstWord[0]);
|
||||||
|
#else
|
||||||
|
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
||||||
|
UnicodeString ucFirstLetter = firstLetter.toUpper();
|
||||||
|
ucFirstLetter.toUTF8String(ucFirstWord);
|
||||||
|
ucFirstWord += word.substr(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ucFirstWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 new_string = word;
|
std::string ucFirstWord;
|
||||||
new_string[0] = tolower(new_string[0]);
|
|
||||||
|
|
||||||
return new_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
ucFirstWord = word;
|
||||||
|
ucFirstWord[0] = tolower(ucFirstWord[0]);
|
||||||
|
#else
|
||||||
|
UnicodeString firstLetter = UnicodeString(word.substr(0, 1).c_str());
|
||||||
|
UnicodeString ucFirstLetter = firstLetter.toLower();
|
||||||
|
ucFirstLetter.toUTF8String(ucFirstWord);
|
||||||
|
ucFirstWord += word.substr(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return ucFirstWord;
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <unicode/uniset.h>
|
#include <unicode/uniset.h>
|
||||||
#include <unicode/ustring.h>
|
#include <unicode/ustring.h>
|
||||||
#include <unicode/ucnv.h>
|
#include <unicode/ucnv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -38,12 +38,17 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace kiwix {
|
namespace kiwix {
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
|
|
||||||
std::string removeAccents(const std::string &text);
|
std::string removeAccents(const std::string &text);
|
||||||
std::string beautifyInteger(const unsigned int number);
|
std::string beautifyInteger(const unsigned int number);
|
||||||
|
std::string urlEncode(const std::string &c);
|
||||||
|
std::string urlDecode(const std::string &c);
|
||||||
void printStringInHexadecimal(const char *s);
|
void printStringInHexadecimal(const char *s);
|
||||||
void printStringInHexadecimal(UnicodeString s);
|
void printStringInHexadecimal(UnicodeString s);
|
||||||
|
void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string&, const std::string&);
|
std::vector<std::string> split(const std::string&, const std::string&);
|
||||||
|
@ -53,13 +58,6 @@ namespace kiwix {
|
||||||
|
|
||||||
std::string ucFirst(const std::string &word);
|
std::string ucFirst(const std::string &word);
|
||||||
std::string lcFirst(const std::string &word);
|
std::string lcFirst(const std::string &word);
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
|
||||||
void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr);
|
|
||||||
|
|
||||||
std::string urlEncode(const std::string &c);
|
|
||||||
std::string urlDecode(const std::string &c);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue