Charset default to UTF-8 on Windows

This commit is contained in:
xia-chu
2024-04-20 22:25:21 +08:00
parent 44d6457108
commit e4de454d5d
8 changed files with 8 additions and 38 deletions

View File

@@ -683,34 +683,10 @@ void HttpSession::sendResponse(int code,
AsyncSender::onSocketFlushed(data);
}
string HttpSession::urlDecodePath(const string &str) {
auto ret = strCoding::UrlDecodePath(str);
#ifdef _WIN32
GET_CONFIG(string, charSet, Http::kCharSet);
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
if (isGb2312) {
ret = strCoding::UTF8ToGB2312(ret);
}
#endif // _WIN32
return ret;
}
string HttpSession::urlDecodeComponent(const string &str) {
auto ret = strCoding::UrlDecodeComponent(str);
#ifdef _WIN32
GET_CONFIG(string, charSet, Http::kCharSet);
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
if (isGb2312) {
ret = strCoding::UTF8ToGB2312(ret);
}
#endif // _WIN32
return ret;
}
void HttpSession::urlDecode(Parser &parser) {
parser.setUrl(urlDecodePath(parser.url()));
parser.setUrl(strCoding::UrlDecodePath(parser.url()));
for (auto &pr : _parser.getUrlArgs()) {
const_cast<string &>(pr.second) = urlDecodeComponent(pr.second);
const_cast<string &>(pr.second) = strCoding::UrlDecodeComponent(pr.second);
}
}