@@ -43,6 +43,7 @@ public static unsafe bool Is<T>(this TypedReference reference, [MaybeNullWhen(fa
43
43
return false ;
44
44
}
45
45
}
46
+
46
47
#endif
47
48
48
49
/// <summary>
@@ -1019,7 +1020,7 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
1019
1020
for ( int i = 0 ; i < utf16Length; i++ )
1020
1021
{
1021
1022
if ( utf8Bytes >= utf8BytesEnd)
1022
- return ( int ) ( utf8Bytes - start ) ;
1023
+ return 0 ;
1023
1024
1024
1025
char utf16Char = utf16Chars[ i] ;
1025
1026
@@ -1035,15 +1036,15 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
1035
1036
case <= 0x7FF :
1036
1037
// 2-byte UTF-8
1037
1038
if ( utf8Bytes + 1 >= utf8BytesEnd)
1038
- return ( int ) ( utf8Bytes - start ) ;
1039
+ return 0 ;
1039
1040
1040
1041
* utf8Bytes = ( byte ) ( 0xC0 | ( codePoint >> 6 ) ) ;
1041
1042
utf8Bytes++ ;
1042
1043
* utf8Bytes = ( byte ) ( 0x80 | ( codePoint & 0x3F ) ) ;
1043
1044
utf8Bytes++ ;
1044
1045
break ;
1045
1046
1046
- case >= 0xD800 and <= 0xDFFF :
1047
+ case >= 0xD800 and <= 0xDBFF :
1047
1048
if ( i + 1 < utf16Length)
1048
1049
{
1049
1050
char lowSurrogate = utf16Chars[ i + 1 ] ;
@@ -1054,7 +1055,7 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
1054
1055
1055
1056
// This results in a 4-byte UTF-8 sequence
1056
1057
if ( utf8Bytes + 3 >= utf8BytesEnd)
1057
- return ( int ) ( utf8Bytes - start ) ;
1058
+ return 0 ;
1058
1059
1059
1060
* utf8Bytes = ( byte ) ( 0xF0 | ( codePointSurrogate >> 18 ) ) ;
1060
1061
utf8Bytes++ ;
@@ -1071,12 +1072,12 @@ public static unsafe int ConvertUtf16ToUtf8(char* utf16Chars, int utf16Length, b
1071
1072
}
1072
1073
}
1073
1074
1074
- return ( int ) ( utf8Bytes - start ) ;
1075
+ return 0 ;
1075
1076
1076
1077
default :
1077
1078
// 3-byte UTF-8
1078
1079
if ( utf8Bytes + 2 >= utf8BytesEnd)
1079
- return ( int ) ( utf8Bytes - start ) ;
1080
+ return 0 ;
1080
1081
1081
1082
* utf8Bytes = ( byte ) ( 0xE0 | ( codePoint >> 12 ) ) ;
1082
1083
utf8Bytes++ ;
@@ -1520,35 +1521,36 @@ public static string GetTimeSpanPattern(string formatSpecifier = "G")
1520
1521
_ => throw new FormatException ( "Unknown format specifier" )
1521
1522
} ;
1522
1523
}
1523
- public unsafe static int Format( TimeSpan timeSpan , Span < byte > buf )
1524
+
1525
+ public static unsafe int Format( TimeSpan timeSpan , Span < byte > buf )
1524
1526
{
1525
1527
fixed ( byte * pBuf = buf)
1526
1528
return Format( timeSpan , pBuf , buf . Length , TimeSpanDefaultPattern , CultureInfo . CurrentCulture ) ;
1527
1529
}
1528
1530
1529
- public unsafe static int Format( TimeSpan timeSpan , Span < byte > buf , string format )
1531
+ public static unsafe int Format( TimeSpan timeSpan , Span < byte > buf , string format )
1530
1532
{
1531
1533
fixed ( byte * pBuf = buf)
1532
1534
return Format( timeSpan , pBuf , buf . Length , format , CultureInfo . CurrentCulture ) ;
1533
1535
}
1534
1536
1535
- public unsafe static int Format( TimeSpan timeSpan , Span < byte > buf , string format , CultureInfo cultureInfo )
1537
+ public static unsafe int Format( TimeSpan timeSpan , Span < byte > buf , string format , CultureInfo cultureInfo )
1536
1538
{
1537
1539
fixed ( byte * pBuf = buf)
1538
1540
return Format( timeSpan , pBuf , buf . Length , format , cultureInfo ) ;
1539
1541
}
1540
1542
1541
- public unsafe static int Format( TimeSpan timeSpan , byte * buf , int bufSize )
1543
+ public static unsafe int Format( TimeSpan timeSpan , byte * buf , int bufSize )
1542
1544
{
1543
1545
return Format( timeSpan , buf , bufSize , TimeSpanDefaultPattern , CultureInfo . CurrentCulture ) ;
1544
1546
}
1545
1547
1546
- public unsafe static int Format( TimeSpan timeSpan , byte * buf , int bufSize , string format )
1548
+ public static unsafe int Format( TimeSpan timeSpan , byte * buf , int bufSize , string format )
1547
1549
{
1548
1550
return Format( timeSpan , buf , bufSize , format , CultureInfo . CurrentCulture ) ;
1549
1551
}
1550
1552
1551
- public unsafe static int Format( TimeSpan timeSpan , byte * buf , int bufSize , string format , CultureInfo cultureInfo )
1553
+ public static unsafe int Format( TimeSpan timeSpan , byte * buf , int bufSize , string format , CultureInfo cultureInfo )
1552
1554
{
1553
1555
if ( bufSize == 0 )
1554
1556
{
@@ -1752,7 +1754,7 @@ private static unsafe int WriteTwoDigitInt(byte* buf, int bufSize, int padding,
1752
1754
}
1753
1755
1754
1756
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
1755
- private unsafe static int IndexOf ( char * str , char * strEnd , char target )
1757
+ private static unsafe int IndexOf( char * str , char * strEnd , char target )
1756
1758
{
1757
1759
char * start = str;
1758
1760
while ( str != strEnd && * str != target )
@@ -1843,7 +1845,7 @@ private static unsafe bool Format(TimeSpan timeSpan, byte* buf, int* idx, int ma
1843
1845
}
1844
1846
1845
1847
[ MethodImpl( MethodImplOptions. AggressiveInlining) ]
1846
- private unsafe static int CountAhead( char * * format, char * formatEnd, char target, int max)
1848
+ private static unsafe int CountAhead( char * * format, char * formatEnd, char target, int max)
1847
1849
{
1848
1850
int count = 0 ;
1849
1851
char * pChar = * format;
0 commit comments