mirror of https://github.com/kiwix/libkiwix.git
moved loadICUExternalTables code to stringTools so it can be used by kiwix-serve
This commit is contained in:
parent
c99cd00be4
commit
38108f064e
|
@ -34,16 +34,7 @@ namespace kiwix {
|
|||
resultRange(20)
|
||||
{
|
||||
template_ct2 = getResourceAsString("results.ct2");
|
||||
#ifdef __APPLE__
|
||||
string executablePath = getExecutablePath();
|
||||
string executableDirectory = removeLastPathElement(executablePath);
|
||||
string datPath = computeAbsolutePath(executableDirectory, "icudt49l.dat");
|
||||
try {
|
||||
u_setDataDirectory(datPath.c_str());
|
||||
} catch (exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
#endif
|
||||
loadICUExternalTables();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,20 @@
|
|||
|
||||
#include "stringTools.h"
|
||||
|
||||
/* tell ICU where to find its dat file (tables) */
|
||||
void kiwix::loadICUExternalTables() {
|
||||
#ifdef __APPLE__
|
||||
std::string executablePath = getExecutablePath();
|
||||
std::string executableDirectory = removeLastPathElement(executablePath);
|
||||
std::string datPath = computeAbsolutePath(executableDirectory, "icudt49l.dat");
|
||||
try {
|
||||
u_setDataDirectory(datPath.c_str());
|
||||
} catch (exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
|
||||
/* Prepare integer for display */
|
||||
|
@ -37,6 +51,7 @@ std::string kiwix::beautifyInteger(const unsigned int number) {
|
|||
}
|
||||
|
||||
std::string kiwix::removeAccents(const std::string &text) {
|
||||
loadICUExternalTables();
|
||||
ucnv_setDefaultName("UTF-8");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Transliterator *removeAccentsTrans = Transliterator::createInstance("Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status);
|
||||
|
@ -179,7 +194,7 @@ std::string kiwix::ucFirst (const std::string &word) {
|
|||
UnicodeString unicodeWord(word.c_str());
|
||||
UnicodeString unicodeFirstLetter = UnicodeString(unicodeWord, 0, 1).toUpper();
|
||||
unicodeWord.replace(0, 1, unicodeFirstLetter);
|
||||
unicodeWord.toUTF8String(result);
|
||||
unicodeWord.toUTF8String(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <pathTools.h>
|
||||
|
||||
namespace kiwix {
|
||||
|
||||
#ifndef __ANDROID__
|
||||
|
@ -48,6 +50,7 @@ namespace kiwix {
|
|||
|
||||
#endif
|
||||
|
||||
void loadICUExternalTables();
|
||||
std::string urlDecode(const std::string &c);
|
||||
|
||||
std::vector<std::string> split(const std::string&, const std::string&);
|
||||
|
|
Loading…
Reference in New Issue