From 6ae73aaa7db614f132899badd9feb22c2684bf21 Mon Sep 17 00:00:00 2001 From: MattMo Date: Mon, 6 Feb 2023 12:46:02 -0800 Subject: [PATCH] Changed response extensions to use utf-8 encoding instead of utf-16. Bumped package version to 1.2.6 --- Rest.Net/HttpListenerResponseExtensions.cs | 12 ++++++------ Rest.Net/Rest.Net.csproj | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Rest.Net/HttpListenerResponseExtensions.cs b/Rest.Net/HttpListenerResponseExtensions.cs index 1e15cbe..0a360ae 100644 --- a/Rest.Net/HttpListenerResponseExtensions.cs +++ b/Rest.Net/HttpListenerResponseExtensions.cs @@ -22,9 +22,9 @@ namespace MontoyaTech.Rest.Net /// This response. public static HttpListenerResponse WithText(this HttpListenerResponse response, string text) { - response.ContentType = "text/plain; charset=utf-16"; + response.ContentType = "text/plain; charset=utf-8"; - var bytes = Encoding.Unicode.GetBytes(text); + var bytes = Encoding.UTF8.GetBytes(text); response.OutputStream.Write(bytes, 0, bytes.Length); return response; @@ -38,9 +38,9 @@ namespace MontoyaTech.Rest.Net /// This response. public static HttpListenerResponse WithJson(this HttpListenerResponse response, object obj) { - response.ContentType = "application/json; charset=utf-16"; + response.ContentType = "application/json; charset=utf-8"; - var bytes = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(obj)); + var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(obj)); response.OutputStream.Write(bytes, 0, bytes.Length); return response; @@ -73,9 +73,9 @@ namespace MontoyaTech.Rest.Net /// This response. public static HttpListenerResponse WithHtml(this HttpListenerResponse response, string html) { - response.ContentType = "text/html; charset=utf-16"; + response.ContentType = "text/html; charset=utf-8"; - var bytes = Encoding.Unicode.GetBytes(html); + var bytes = Encoding.UTF8.GetBytes(html); response.OutputStream.Write(bytes, 0, bytes.Length); return response; diff --git a/Rest.Net/Rest.Net.csproj b/Rest.Net/Rest.Net.csproj index f0d8f88..768c382 100644 --- a/Rest.Net/Rest.Net.csproj +++ b/Rest.Net/Rest.Net.csproj @@ -17,7 +17,7 @@ MontoyaTech.Rest.Net MontoyaTech.Rest.Net True - 1.2.5 + 1.2.6 Logo_Symbol_Black_Outline.png