77 using System . Text ;
88
99#if NET5_0_OR_GREATER
10+
1011 /// <summary>
1112 /// Helper class to work with the hidden C# Feature TypedReference.
1213 /// </summary>
@@ -1045,19 +1046,16 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
10451046 switch ( codePoint )
10461047 {
10471048 case <= 0x7F :
1048- * utf8Bytes = ( byte ) codePoint ;
1049- utf8Bytes ++ ;
1049+ * utf8Bytes ++ = ( byte ) codePoint ;
10501050 break ;
10511051
10521052 case <= 0x7FF :
10531053 // 2-byte UTF-8
10541054 if ( utf8Bytes + 1 >= utf8BytesEnd )
10551055 return 0 ;
10561056
1057- * utf8Bytes = ( byte ) ( 0xC0 | ( codePoint >> 6 ) ) ;
1058- utf8Bytes ++ ;
1059- * utf8Bytes = ( byte ) ( 0x80 | ( codePoint & 0x3F ) ) ;
1060- utf8Bytes ++ ;
1057+ * utf8Bytes ++ = ( byte ) ( 0xC0 | ( codePoint >> 6 ) ) ;
1058+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( codePoint & 0x3F ) ) ;
10611059 break ;
10621060
10631061 case >= 0xD800 and <= 0xDBFF :
@@ -1073,14 +1071,10 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
10731071 if ( utf8Bytes + 3 >= utf8BytesEnd )
10741072 return 0 ;
10751073
1076- * utf8Bytes = ( byte ) ( 0xF0 | ( codePointSurrogate >> 18 ) ) ;
1077- utf8Bytes ++ ;
1078- * utf8Bytes = ( byte ) ( 0x80 | ( ( codePointSurrogate >> 12 ) & 0x3F ) ) ;
1079- utf8Bytes ++ ;
1080- * utf8Bytes = ( byte ) ( 0x80 | ( ( codePointSurrogate >> 6 ) & 0x3F ) ) ;
1081- utf8Bytes ++ ;
1082- * utf8Bytes = ( byte ) ( 0x80 | ( codePointSurrogate & 0x3F ) ) ;
1083- utf8Bytes ++ ;
1074+ * utf8Bytes ++ = ( byte ) ( 0xF0 | ( codePointSurrogate >> 18 ) ) ;
1075+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( ( codePointSurrogate >> 12 ) & 0x3F ) ) ;
1076+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( ( codePointSurrogate >> 6 ) & 0x3F ) ) ;
1077+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( codePointSurrogate & 0x3F ) ) ;
10841078
10851079 // Skip the low surrogate as it has already been processed
10861080 i ++ ;
@@ -1095,12 +1089,9 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
10951089 if ( utf8Bytes + 2 >= utf8BytesEnd )
10961090 return 0 ;
10971091
1098- * utf8Bytes = ( byte ) ( 0xE0 | ( codePoint >> 12 ) ) ;
1099- utf8Bytes ++ ;
1100- * utf8Bytes = ( byte ) ( 0x80 | ( ( codePoint >> 6 ) & 0x3F ) ) ;
1101- utf8Bytes ++ ;
1102- * utf8Bytes = ( byte ) ( 0x80 | ( codePoint & 0x3F ) ) ;
1103- utf8Bytes ++ ;
1092+ * utf8Bytes ++ = ( byte ) ( 0xE0 | ( codePoint >> 12 ) ) ;
1093+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( ( codePoint >> 6 ) & 0x3F ) ) ;
1094+ * utf8Bytes ++ = ( byte ) ( 0x80 | ( codePoint & 0x3F ) ) ;
11041095 break ;
11051096 }
11061097 }
@@ -1876,4 +1867,4 @@ private static unsafe int CountAhead(char** format, char* formatEnd, char target
18761867 return count ;
18771868 }
18781869 }
1879- }
1870+ }
0 commit comments