File tree Expand file tree Collapse file tree 1 file changed +1
-13
lines changed
Expand file tree Collapse file tree 1 file changed +1
-13
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,6 @@ namespace RestSharp.Extensions
2121{
2222 public static class StringEncodingExtensions
2323 {
24- static readonly Dictionary < string , Encoding > Encodings = new Dictionary < string , Encoding > ( ) ;
25-
26- static StringEncodingExtensions ( )
27- {
28- var encodings = Encoding . GetEncodings ( ) ;
29-
30- foreach ( var encoding in encodings )
31- {
32- Encodings [ encoding . Name ] = encoding . GetEncoding ( ) ;
33- }
34- }
35-
3624 /// <summary>
3725 /// Converts a byte array to a string, using its byte order mark to convert it to the right encoding.
3826 /// http://www.shrinkrays.net/code-snippets/csharp/an-extension-method-for-converting-a-byte-array-to-a-string.aspx
@@ -43,7 +31,7 @@ static StringEncodingExtensions()
4331 [ Obsolete ( "This method will be removed soon. If you use it, please copy the code to your project." ) ]
4432 public static string AsString ( this byte [ ] buffer , string ? encoding )
4533 {
46- var enc = encoding . IsEmpty ( ) ? Encoding . UTF8 : Encodings . TryGetValue ( encoding ! , out var e ) ? e : Encoding . UTF8 ;
34+ var enc = encoding . IsEmpty ( ) ? Encoding . UTF8 : Encoding . GetEncoding ( encoding ) ?? Encoding . UTF8 ;
4735
4836 return AsString ( buffer , enc ) ;
4937 }
You can’t perform that action at this time.
0 commit comments