mirror of https://github.com/kiwix/libkiwix.git
+ change call of function appendToFirstOccurence() and replaceRegex()
This commit is contained in:
parent
084af011dd
commit
28138e7ff9
|
@ -63,10 +63,10 @@ namespace kiwix {
|
||||||
std::string id = path;
|
std::string id = path;
|
||||||
if (!id.empty()) {
|
if (!id.empty()) {
|
||||||
removeAccents(id);
|
removeAccents(id);
|
||||||
replaceRegex(id, "", "^.*/");
|
id = replaceRegex(id, "", "^.*/");
|
||||||
replaceRegex(id, "", "\\.zim[a-z]*$");
|
id = replaceRegex(id, "", "\\.zim[a-z]*$");
|
||||||
replaceRegex(id, "_", " ");
|
id = replaceRegex(id, "_", " ");
|
||||||
replaceRegex(id, "plus", "\\+");
|
id = replaceRegex(id, "plus", "\\+");
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ bool matchRegex(const std::string &content, const std::string ®ex) {
|
||||||
return matcher->find();
|
return matcher->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
void replaceRegex(std::string &content, const std::string &replacement, const std::string ®ex) {
|
std::string replaceRegex(const std::string &content, const std::string &replacement, const std::string ®ex) {
|
||||||
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());
|
UnicodeString ureplacement = UnicodeString(replacement.c_str());
|
||||||
|
@ -63,10 +63,10 @@ void replaceRegex(std::string &content, const std::string &replacement, const st
|
||||||
UnicodeString uresult = matcher->replaceAll(ureplacement, status);
|
UnicodeString uresult = matcher->replaceAll(ureplacement, status);
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
uresult.toUTF8String(tmp);
|
uresult.toUTF8String(tmp);
|
||||||
content=tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement) {
|
std::string appendToFirstOccurence(const 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());
|
UnicodeString ureplacement = UnicodeString(replacement.c_str());
|
||||||
|
@ -78,7 +78,9 @@ void appendToFirstOccurence(std::string &content, const std::string regex, cons
|
||||||
ucontent.insert(matcher->end(status), ureplacement);
|
ucontent.insert(matcher->end(status), ureplacement);
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
ucontent.toUTF8String(tmp);
|
ucontent.toUTF8String(tmp);
|
||||||
content=tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
bool matchRegex(const std::string &content, const std::string ®ex);
|
bool matchRegex(const std::string &content, const std::string ®ex);
|
||||||
void replaceRegex(std::string &content, const std::string &replacement, const std::string ®ex);
|
std::string replaceRegex(const std::string &content, const std::string &replacement, const std::string ®ex);
|
||||||
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement);
|
std::string appendToFirstOccurence(const std::string &content, const std::string regex, const std::string &replacement);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue