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:
ragnarok-clanker 2026-11-05 12:30:18 +00:00
commit 2a768fc6d8

View file

@ -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)));
}