forked from Public-Mirror/Textractor
fix single byte hooks
This commit is contained in:
parent
4e9df97991
commit
0d9976b0c4
@ -28,6 +28,12 @@ void TextThread::Push(const BYTE* data, int len)
|
||||
{
|
||||
if (len < 0) return;
|
||||
std::scoped_lock lock(bufferMutex);
|
||||
|
||||
BYTE doubleByteChar[2];
|
||||
if (len == 1) // doublebyte characters must be processed as pairs
|
||||
if (leadByte) std::tie(doubleByteChar[0], doubleByteChar[1], data, len, leadByte) = std::tuple(leadByte, data[0], doubleByteChar, 2, 0 );
|
||||
else if (IsDBCSLeadByteEx(hp.codepage ? hp.codepage : Host::defaultCodepage, data[0])) std::tie(leadByte, len) = std::tuple(data[0], 0);
|
||||
|
||||
if (hp.type & USING_UNICODE) buffer += std::wstring((wchar_t*)data, len / 2);
|
||||
else if (auto converted = Util::StringToWideString(std::string((char*)data, len), hp.codepage ? hp.codepage : Host::defaultCodepage)) buffer += converted.value();
|
||||
else Host::AddConsoleOutput(INVALID_CODEPAGE);
|
||||
|
@ -32,9 +32,10 @@ private:
|
||||
void Flush();
|
||||
|
||||
std::wstring buffer;
|
||||
BYTE leadByte = 0;
|
||||
std::unordered_set<wchar_t> repeatingChars;
|
||||
std::mutex bufferMutex;
|
||||
DWORD lastPushTime;
|
||||
DWORD lastPushTime = 0;
|
||||
ThreadSafe<std::vector<std::wstring>> queuedSentences;
|
||||
struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
||||
AutoHandle<TimerDeleter> timer = NULL; // this needs to be last so it's destructed first
|
||||
|
Loading…
x
Reference in New Issue
Block a user