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
21
21
{
22
22
public static class StringEncodingExtensions
23
23
{
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
-
36
24
/// <summary>
37
25
/// Converts a byte array to a string, using its byte order mark to convert it to the right encoding.
38
26
/// 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()
43
31
[ Obsolete ( "This method will be removed soon. If you use it, please copy the code to your project." ) ]
44
32
public static string AsString ( this byte [ ] buffer , string ? encoding )
45
33
{
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 ;
47
35
48
36
return AsString ( buffer , enc ) ;
49
37
}
You can’t perform that action at this time.
0 commit comments