Decompile 2 functions in Source/Network/TextEncoding.cpp
Batch #12147 by cremane: 0 byte-identical, 2 confirmed by peer review. - fn_18265 EncodeText: logic confirmed by peer review - fn_02795 FindSubstring: logic confirmed by peer review Peer-reviewed-by: Yommy, Tanke Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
dd95a31022
commit
2a768fc6d8
1 changed files with 4 additions and 7 deletions
|
|
@ -135,15 +135,15 @@ std::wstring DecodeText(UINT codePage, const std::string& text) {
|
|||
std::string EncodeText(UINT codePage, const std::wstring& text) {
|
||||
const int length = WideCharToMultiByte(codePage, 0, text.c_str(), -1, nullptr, 0, nullptr, nullptr);
|
||||
if (length == 0) {
|
||||
return {};
|
||||
return "";
|
||||
}
|
||||
char* converted = static_cast<char*>(std::malloc(length));
|
||||
if (converted == nullptr) {
|
||||
return {};
|
||||
return "";
|
||||
}
|
||||
if (WideCharToMultiByte(codePage, 0, text.c_str(), -1, converted, length, nullptr, nullptr) == 0) {
|
||||
std::free(converted);
|
||||
return {};
|
||||
return "";
|
||||
}
|
||||
std::string result(converted, std::strlen(converted));
|
||||
std::free(converted);
|
||||
|
|
@ -161,9 +161,6 @@ std::wstring LowercaseWide(const std::string& text) {
|
|||
// OFFSET: 0x0058D6B0
|
||||
// FUNCTION: fn_02795
|
||||
int FindSubstring(const char* text, int codePage, const char* pattern) {
|
||||
std::wstring wideText = LowercaseWide(text);
|
||||
std::wstring widePattern = LowercaseWide(pattern);
|
||||
size_t pos = wideText.find(widePattern);
|
||||
return (pos == std::wstring::npos) ? -1 : static_cast<int>(pos);
|
||||
return static_cast<int>(LowercaseWide(text).find(LowercaseWide(pattern)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue