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)
|
resultRange(20)
|
||||||
{
|
{
|
||||||
template_ct2 = getResourceAsString("results.ct2");
|
template_ct2 = getResourceAsString("results.ct2");
|
||||||
#ifdef __APPLE__
|
loadICUExternalTables();
|
||||||
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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,20 @@
|
||||||
|
|
||||||
#include "stringTools.h"
|
#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__
|
#ifndef __ANDROID__
|
||||||
|
|
||||||
/* Prepare integer for display */
|
/* Prepare integer for display */
|
||||||
|
@ -37,6 +51,7 @@ std::string kiwix::beautifyInteger(const unsigned int number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string kiwix::removeAccents(const std::string &text) {
|
std::string kiwix::removeAccents(const std::string &text) {
|
||||||
|
loadICUExternalTables();
|
||||||
ucnv_setDefaultName("UTF-8");
|
ucnv_setDefaultName("UTF-8");
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
Transliterator *removeAccentsTrans = Transliterator::createInstance("Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status);
|
Transliterator *removeAccentsTrans = Transliterator::createInstance("Lower; NFD; [:M:] remove; NFC", UTRANS_FORWARD, status);
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <pathTools.h>
|
||||||
|
|
||||||
namespace kiwix {
|
namespace kiwix {
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
|
@ -48,6 +50,7 @@ namespace kiwix {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void loadICUExternalTables();
|
||||||
std::string urlDecode(const std::string &c);
|
std::string urlDecode(const std::string &c);
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string&, const std::string&);
|
std::vector<std::string> split(const std::string&, const std::string&);
|
||||||
|
|
Loading…
Reference in New Issue