File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,25 +9,27 @@ namespace Oxide.CompilerServices;
99public class Serializer : ISerializer
1010{
1111 private readonly JsonSerializer _jsonSerializer ;
12+ private readonly UTF8Encoding _encoding ;
1213
1314 public Serializer ( )
1415 {
1516 _jsonSerializer = new JsonSerializer ( ) ;
17+ _encoding = new UTF8Encoding ( false ) ;
1618 }
1719
1820 public byte [ ] Serialize < T > ( T type ) where T : class
1921 {
2022 using MemoryStream memoryStream = new ( ) ;
21- using StreamWriter writer = new ( memoryStream , Encoding . UTF8 ) ;
22- _jsonSerializer . Serialize ( writer , type ) ;
23- writer . Flush ( ) ;
23+ using StreamWriter streamWriter = new ( memoryStream , _encoding ) ;
24+ _jsonSerializer . Serialize ( streamWriter , type ) ;
25+ streamWriter . Flush ( ) ;
2426 return memoryStream . ToArray ( ) ;
2527 }
2628
2729 public T Deserialize < T > ( byte [ ] data ) where T : class
2830 {
2931 using MemoryStream memoryStream = new ( data ) ;
30- using StreamReader reader = new ( memoryStream , Encoding . UTF8 ) ;
31- return ( T ) _jsonSerializer . Deserialize ( reader , typeof ( T ) ) ;
32+ using StreamReader streamReader = new ( memoryStream , _encoding ) ;
33+ return ( T ) _jsonSerializer . Deserialize ( streamReader , typeof ( T ) ) ;
3234 }
3335}
You can’t perform that action at this time.
0 commit comments