@@ -310,32 +310,6 @@ private static unsafe void Write(int fd, byte[] buffer, int offset, int count)
310
310
}
311
311
}
312
312
313
- /// <summary>Creates a string from an array of ASCII bytes.</summary>
314
- /// <param name="buffer">The byte buffer.</param>
315
- /// <param name="offset">The starting location in the buffer from which to begin the string.</param>
316
- /// <param name="length">The length of the resulting string.</param>
317
- /// <returns>
318
- /// A string containing characters copied from the buffer, one character per byte starting
319
- /// from <paramref name="offset"/> and going for <paramref name="length"/> bytes.
320
- /// </returns>
321
- private static string StringFromAsciiBytes ( byte [ ] buffer , int offset , int length )
322
- {
323
- // Special-case for empty strings
324
- if ( length == 0 )
325
- {
326
- return string . Empty ;
327
- }
328
-
329
- // new string(sbyte*, ...) doesn't exist in the targeted reference assembly,
330
- // so we first copy to an array of chars, and then create a string from that.
331
- char [ ] chars = new char [ length ] ;
332
- for ( int i = 0 , j = offset ; i < length ; i ++ , j ++ )
333
- {
334
- chars [ i ] = ( char ) buffer [ j ] ;
335
- }
336
- return new string ( chars ) ;
337
- }
338
-
339
313
/// <summary>Provides a stream to use for Unix console input or output.</summary>
340
314
private sealed class UnixConsoleStream : ConsoleStream
341
315
{
@@ -699,7 +673,7 @@ private static string ReadString(byte[] buffer, int pos)
699
673
{
700
674
findNullEnding ++ ;
701
675
}
702
- return StringFromAsciiBytes ( buffer , pos , findNullEnding - pos ) ;
676
+ return Encoding . ASCII . GetString ( buffer , pos , findNullEnding - pos ) ;
703
677
}
704
678
}
705
679
@@ -1043,7 +1017,7 @@ private static unsafe string FormatPrintF(string format, object arg)
1043
1017
throw new InvalidOperationException ( SR . InvalidOperation_PrintF ) ;
1044
1018
}
1045
1019
}
1046
- return StringFromAsciiBytes ( bytes , 0 , neededLength ) ;
1020
+ return Encoding . ASCII . GetString ( bytes , 0 , neededLength ) ;
1047
1021
}
1048
1022
1049
1023
/// <summary>Gets the lazily-initialized dynamic or static variables collection, based on the supplied variable name.</summary>
0 commit comments