Skip to content

Commit

Permalink
Fixed special characters causing errors due to not converting to ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Andrews committed Feb 20, 2019
1 parent a73a299 commit d203141
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions RedisMessagePackFormatter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text;
using MessagePack;
using Newtonsoft.Json;

Expand Down Expand Up @@ -28,13 +29,17 @@ private static void DecodeMessagePack()
var bytes = Convert.FromBase64CharArray(input.ToCharArray(), 0, input.Length);
var messagePackObject = MessagePackSerializer.Typeless.Deserialize(bytes);
var prettyJson = JsonConvert.SerializeObject(messagePackObject, Formatting.Indented);
Console.Write(JsonConvert.SerializeObject(new DecodeResponse(prettyJson)));

// Convert to ASCII because that's all RDM supports
var asciiBytes = Encoding.ASCII.GetBytes(prettyJson);
var asciiPrettyJson = Encoding.ASCII.GetString(asciiBytes);
Console.Write(JsonConvert.SerializeObject(new DecodeResponse(asciiPrettyJson)));
}
}

private static void OutputFormatterInfo()
{
var info = new {version = "1.0.0", description = "MessagePack Formatter"};
var info = new {version = "1.1.0", description = "MessagePack Formatter"};
Console.Write(JsonConvert.SerializeObject(info));
}
}
Expand Down

0 comments on commit d203141

Please sign in to comment.