diff --git a/neo-cli/CLI/MainService.Tools.cs b/neo-cli/CLI/MainService.Tools.cs index 0686ddb8d..6c8f27cc7 100644 --- a/neo-cli/CLI/MainService.Tools.cs +++ b/neo-cli/CLI/MainService.Tools.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; -using System.Text; namespace Neo.CLI { @@ -70,7 +69,7 @@ private string HexToString(string hexString) { var clearHexString = ClearHexString(hexString); var bytes = clearHexString.HexToBytes(); - var utf8String = Encoding.UTF8.GetString(bytes); + var utf8String = Utility.StrictUTF8.GetString(bytes); if (!IsPrintable(utf8String)) { @@ -170,7 +169,7 @@ private string StringToHex(string strParam) { try { - var bytesParam = Encoding.UTF8.GetBytes(strParam); + var bytesParam = Utility.StrictUTF8.GetBytes(strParam); return bytesParam.ToHexString(); } catch @@ -196,7 +195,7 @@ private string StringToBase64(string strParam) { try { - byte[] bytearray = Encoding.UTF8.GetBytes(strParam); + byte[] bytearray = Utility.StrictUTF8.GetBytes(strParam); string base64 = Convert.ToBase64String(bytearray.AsSpan()); return base64; } @@ -407,7 +406,7 @@ private string Base64ToString(string bytearray) try { byte[] result = Convert.FromBase64String(bytearray); - string utf8string = Encoding.UTF8.GetString(result); + string utf8string = Utility.StrictUTF8.GetString(result); if (!IsPrintable(utf8string)) { diff --git a/neo-cli/CLI/MainService.cs b/neo-cli/CLI/MainService.cs index 2dc8de110..176151f57 100644 --- a/neo-cli/CLI/MainService.cs +++ b/neo-cli/CLI/MainService.cs @@ -24,7 +24,6 @@ using System.Linq; using System.Net; using System.Reflection; -using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -263,7 +262,7 @@ private byte[] LoadDeploymentScript(string nefFilePath, string manifestFilePath, } NefFile file; - using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Encoding.UTF8, false)) + using (var stream = new BinaryReader(File.OpenRead(nefFilePath), Utility.StrictUTF8, false)) { file = stream.ReadSerializable(); }