Skip to content

Commit

Permalink
When writing results to the output stream, use a stream writer and UT…
Browse files Browse the repository at this point in the history
…F8 encoding, but do not emit the BOM
  • Loading branch information
spewu committed Jan 18, 2017
1 parent 7a42a7f commit 878ba85
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Aem/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void Main(string[] args)
ciphertext = WebUtility.UrlEncode(ciphertext);
}

Console.Write(ciphertext);
WriteResultToOutput(ciphertext);
break;
case Command.Decrypt:

Expand All @@ -40,7 +40,7 @@ public static void Main(string[] args)

try
{
Console.Write(AuthenticatedEncryption.Decrypt(message, configuration.CryptKey, configuration.AuthKey));
WriteResultToOutput(AuthenticatedEncryption.Decrypt(message, configuration.CryptKey, configuration.AuthKey));
}
catch (FormatException)
{
Expand All @@ -52,6 +52,14 @@ public static void Main(string[] args)
}
}

private static void WriteResultToOutput(string result)
{
using (var streamWriter = new StreamWriter(Console.OpenStandardOutput(), new UTF8Encoding(false)))
{
streamWriter.WriteLine(result);
}
}

private static Arguments ParseArguments(IEnumerable<string> args)
{
var urlEncode = false;
Expand Down

0 comments on commit 878ba85

Please sign in to comment.