-
Notifications
You must be signed in to change notification settings - Fork 9k
Fix for UTF-8 partials in function ConhostConnection::_OutputThread.
#1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ea46579
7c83c38
7a4a814
a424a16
85b5509
5780770
d0e6e82
d98c589
7df6609
507f526
7d8c4b1
f08f31c
bb299d7
c395f3b
23c4286
99d0713
c877edd
e35a78f
31db29b
d09ac87
f23bcd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| #include "pch.h" | ||
| #include "ConhostConnection.h" | ||
| #include "windows.h" | ||
| #include "wil/common.h" | ||
| #include <sstream> | ||
| #include <string_view> | ||
| #include <algorithm> | ||
|
|
@@ -234,16 +235,16 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation | |
| const BYTE* const endPtr{ buffer + dwRead }; | ||
| const BYTE* backIter{ endPtr - 1 }; | ||
| // If the last byte in the buffer was a byte belonging to a UTF-8 multi-byte character | ||
| if ((*backIter & 0b10000000) == 0b10000000) | ||
| if (WI_AreAllFlagsSet(*backIter & 0b10000000, 0b10000000)) | ||
|
||
| { | ||
| // Check only up to 3 last bytes, if no Lead Byte was found then the byte before must be the Lead Byte and no partials are in the buffer | ||
| for (DWORD dwSequenceLen{ 1UL }, stop{ dwRead < 4UL ? dwRead : 4UL }; dwSequenceLen < stop; ++dwSequenceLen, --backIter) | ||
| { | ||
| // If Lead Byte found | ||
| if ((*backIter & 0b11000000) == 0b11000000) | ||
| if (WI_AreAllFlagsSet(*backIter & 0b11000000, 0b11000000)) | ||
| { | ||
| // If the Lead Byte indicates that the last bytes in the buffer is a partial UTF-8 code point then cache them | ||
| if ((*backIter & bitmasks[dwSequenceLen]) != bitmasks[dwSequenceLen - 1]) | ||
| if (WI_IsAnyFlagClear(*backIter & bitmasks[dwSequenceLen], bitmasks[dwSequenceLen - 1])) | ||
|
||
| { | ||
| std::move(backIter, endPtr, utf8Partials); | ||
| dwRead -= dwSequenceLen; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have wil/common, string_view, algorithm and type_traits in our precompiled header through
pch.h->LibraryIncludes.h!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm used to including the related headers. It's difficult for me to find the way across other header files to figure out which have been already included over detours.
Before I push the next commit I should probably check if it compiles without string_view, algorithm, and type_traits included directly.