mirror of https://github.com/kiwix/libkiwix.git
FIXED: Kiwix-serve sporadic invisible search box with non-latin contents
This commit is contained in:
parent
8f89edf17c
commit
b17f6a6d01
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "regexTools.h"
|
#include "regexTools.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
std::map<std::string, RegexMatcher*> regexCache;
|
std::map<std::string, RegexMatcher*> regexCache;
|
||||||
|
|
||||||
|
@ -57,12 +56,16 @@ bool matchRegex(const std::string &content, const std::string ®ex) {
|
||||||
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement) {
|
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement) {
|
||||||
ucnv_setDefaultName("UTF-8");
|
ucnv_setDefaultName("UTF-8");
|
||||||
UnicodeString ucontent = UnicodeString(content.c_str());
|
UnicodeString ucontent = UnicodeString(content.c_str());
|
||||||
|
UnicodeString ureplacement = UnicodeString(replacement.c_str());
|
||||||
RegexMatcher *matcher = buildRegex(regex);
|
RegexMatcher *matcher = buildRegex(regex);
|
||||||
matcher->reset(ucontent);
|
matcher->reset(ucontent);
|
||||||
|
|
||||||
if (matcher->find()) {
|
if (matcher->find()) {
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
content.insert(matcher->end(status), replacement);
|
ucontent.insert(matcher->end(status), ureplacement);
|
||||||
|
std::string tmp;
|
||||||
|
ucontent.toUTF8String(tmp);
|
||||||
|
content=tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue