以/utf-8编译选项,导致的编码问题,修正。
This commit is contained in:
@@ -14,17 +14,21 @@ CXmlOpr::~CXmlOpr() = default;
|
||||
|
||||
bool CXmlOpr::open(const std::string& xml_path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (doc_.LoadFile(CUtil::utf8_to_gbk(xml_path).c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
xml_path_ = CUtil::utf8_to_gbk(xml_path);
|
||||
#else
|
||||
// #ifdef _WIN32
|
||||
// if (doc_.LoadFile(CUtil::utf8_to_gbk(xml_path).c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
// return false;
|
||||
// }
|
||||
// xml_path_ = CUtil::utf8_to_gbk(xml_path);
|
||||
// #else
|
||||
// if (doc_.LoadFile(xml_path.c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
// return false;
|
||||
// }
|
||||
// xml_path_ = xml_path;
|
||||
// #endif
|
||||
if (doc_.LoadFile(xml_path.c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
xml_path_ = xml_path;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,8 +268,9 @@ std::string CXmlOpr::handle_space(const std::string& content, const std::vector<
|
||||
}
|
||||
std::string op(keychars[i]);
|
||||
for (const char& c : op) {
|
||||
if (c == '|' || c == '\\' || c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' || c == '^' ||
|
||||
c == '$' || c == '.' || c == '*' || c == '+' || c == '?' || c == '|' || c == '\\') {
|
||||
if (c == '|' || c == '\\' || c == '(' || c == ')' || c == '[' || c == ']' || c == '{' ||
|
||||
c == '}' || c == '^' || c == '$' || c == '.' || c == '*' || c == '+' || c == '?' ||
|
||||
c == '|' || c == '\\') {
|
||||
oss << '\\'; // 添加转义字符
|
||||
}
|
||||
oss << c;
|
||||
|
||||
Reference in New Issue
Block a user