diff --git a/extensions/translatewrapper.cpp b/extensions/translatewrapper.cpp index e6fd790..0043c04 100644 --- a/extensions/translatewrapper.cpp +++ b/extensions/translatewrapper.cpp @@ -174,12 +174,6 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) concurrency::concurrent_priority_queue> tokens; } rateLimiter; - auto Trim = [](std::wstring& text) - { - text.erase(text.begin(), std::find_if_not(text.begin(), text.end(), iswspace)); - text.erase(std::find_if_not(text.rbegin(), text.rend(), iswspace).base(), text.end()); - }; - bool cache = false; std::wstring translation; if (useFilter) diff --git a/host/hookcode.cpp b/host/hookcode.cpp index c7a176d..6673ec6 100644 --- a/host/hookcode.cpp +++ b/host/hookcode.cpp @@ -276,7 +276,9 @@ namespace HookCode { std::optional Parse(std::wstring code) { - if (code[0] == L'/') code.erase(0, 1); // legacy/AGTH compatibility + if (code[0] == L'/') code.erase(0, 1); + code.erase(std::find(code.begin(), code.end(), L'/'), code.end()); // legacy/AGTH compatibility + Trim(code); if (code[0] == L'R') return ParseRCode(code.erase(0, 1)); else if (code[0] == L'H') return ParseHCode(code.erase(0, 1)); return {}; @@ -292,6 +294,7 @@ namespace HookCode assert(HexString(-12) == L"-C"), assert(HexString(12) == L"C"), assert(Parse(L"/HQN936#-c*C:C*1C@4AA:gdi.dll:GetTextOutA")), + assert(Parse(L"/HQN936#-c*C:C*1C@4AA:gdi.dll:GetTextOutA /KF")), assert(Parse(L"HB4@0")), assert(Parse(L"/RS65001#@44")), assert(Parse(L"HQ@4")), diff --git a/include/common.h b/include/common.h index d043fda..665906e 100644 --- a/include/common.h +++ b/include/common.h @@ -120,6 +120,12 @@ inline std::wstring FormatString(const wchar_t* format, const Args&... args) } #pragma warning(pop) +inline void Trim(std::wstring& text) +{ + text.erase(text.begin(), std::find_if_not(text.begin(), text.end(), iswspace)); + text.erase(std::find_if_not(text.rbegin(), text.rend(), iswspace).base(), text.end()); +} + inline std::optional StringToWideString(const std::string& text, UINT encoding) { std::vector buffer(text.size() + 1);