From 72557cb8c45ddec7a4bbf15a8d32689eda156c47 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 23 Sep 2015 17:37:35 -0500 Subject: [PATCH] Read and write UTF-16, not Ascii. --- agent/Agent.cc | 8 ++++---- agent/Win32Console.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/agent/Agent.cc b/agent/Agent.cc index 138de529..ef7e1383 100644 --- a/agent/Agent.cc +++ b/agent/Agent.cc @@ -359,7 +359,7 @@ void Agent::scanForDirtyLines() m_console->read(lineRect, lineData); for (int col = 0; col < windowRect.width(); ++col) { int newAttr = lineData[col].Attributes; - if (lineData[col].Char.AsciiChar != ' ' || attr!= newAttr) + if (lineData[col].Char.UnicodeChar != L' ' || attr != newAttr) m_dirtyLineCount = line + 1; newAttr = attr; } @@ -482,7 +482,7 @@ void Agent::scrapeOutput() memcpy(bufLine, curLine, sizeof(CHAR_INFO) * w); for (int col = w; col < MAX_CONSOLE_WIDTH; ++col) { bufLine[col].Attributes = curLine[w - 1].Attributes; - bufLine[col].Char.AsciiChar = ' '; + bufLine[col].Char.UnicodeChar = L' '; } m_maxBufferedLine = std::max(m_maxBufferedLine, line); sawModifiedLine = true; @@ -521,7 +521,7 @@ void Agent::syncMarkerText(CHAR_INFO *output) sprintf(str, "S*Y*N*C*%08x", m_syncCounter); memset(output, 0, sizeof(CHAR_INFO) * SYNC_MARKER_LEN); for (int i = 0; i < SYNC_MARKER_LEN; ++i) { - output[i].Char.AsciiChar = str[i]; + output[i].Char.UnicodeChar = str[i]; output[i].Attributes = 7; } } @@ -538,7 +538,7 @@ int Agent::findSyncMarker() for (i = m_syncRow; i >= 0; --i) { int j; for (j = 0; j < SYNC_MARKER_LEN; ++j) { - if (column[i + j].Char.AsciiChar != marker[j].Char.AsciiChar) + if (column[i + j].Char.UnicodeChar != marker[j].Char.UnicodeChar) break; } if (j == SYNC_MARKER_LEN) diff --git a/agent/Win32Console.cc b/agent/Win32Console.cc index 5bf91d84..d9dfffae 100644 --- a/agent/Win32Console.cc +++ b/agent/Win32Console.cc @@ -307,7 +307,7 @@ void Win32Console::read(const SmallRect &rect, CHAR_INFO *data) { // TODO: error handling SmallRect tmp(rect); - if (!ReadConsoleOutput(m_conout, data, rect.size(), Coord(), &tmp)) { + if (!ReadConsoleOutputW(m_conout, data, rect.size(), Coord(), &tmp)) { trace("ReadConsoleOutput failed [x:%d,y:%d,w:%d,h:%d]", rect.Left, rect.Top, rect.width(), rect.height()); } @@ -317,7 +317,7 @@ void Win32Console::write(const SmallRect &rect, const CHAR_INFO *data) { // TODO: error handling SmallRect tmp(rect); - if (!WriteConsoleOutput(m_conout, data, rect.size(), Coord(), &tmp)) { + if (!WriteConsoleOutputW(m_conout, data, rect.size(), Coord(), &tmp)) { trace("WriteConsoleOutput failed"); } }