Skip to content

Commit e3dd143

Browse files
GrabYourPitchforksmarek-safar
authored andcommitted
Clarify comment in 3-byte processing
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent 585f556 commit e3dd143

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

netcore/System.Private.CoreLib/shared/System/Text/Unicode/Utf8Utility.Transcoding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ public static OperationStatus TranscodeToUtf16(byte* pInputBuffer, int inputLeng
506506
if (outputCharsRemaining > 1 && (nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) >= 3)
507507
{
508508
// We're going to attempt to read a second 3-byte sequence and write them both out simultaneously using PEXT.
509-
// Since we already validated the first byte of the second DWORD (it's the same as the final byte of the
510-
// first DWORD), the only checks that remain are the overlong + surrogate checks. If the overlong or surrogate
509+
// We need to check the continuation bit mask on the remaining two bytes (and we may as well check the leading
510+
// byte mask again since it's free), then perform overlong + surrogate checks. If the overlong or surrogate
511511
// checks fail, we'll fall through to the remainder of the logic which will transcode the original valid
512512
// 3-byte UTF-8 sequence we read; and on the next iteration of the loop the validation routine will run again,
513513
// fail, and redirect control flow to the error handling logic at the very end of this method.

0 commit comments

Comments
 (0)