Changed response extensions to use utf-8 encoding instead of utf-16. Bumped package version to 1.2.6

This commit is contained in:
MattMo 2023-02-06 12:46:02 -08:00
parent a1f2f4a91c
commit 6ae73aaa7d
2 changed files with 7 additions and 7 deletions

View File

@ -22,9 +22,9 @@ namespace MontoyaTech.Rest.Net
/// <returns>This response.</returns> /// <returns>This response.</returns>
public static HttpListenerResponse WithText(this HttpListenerResponse response, string text) 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); response.OutputStream.Write(bytes, 0, bytes.Length);
return response; return response;
@ -38,9 +38,9 @@ namespace MontoyaTech.Rest.Net
/// <returns>This response.</returns> /// <returns>This response.</returns>
public static HttpListenerResponse WithJson(this HttpListenerResponse response, object obj) 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); response.OutputStream.Write(bytes, 0, bytes.Length);
return response; return response;
@ -73,9 +73,9 @@ namespace MontoyaTech.Rest.Net
/// <returns>This response.</returns> /// <returns>This response.</returns>
public static HttpListenerResponse WithHtml(this HttpListenerResponse response, string html) 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); response.OutputStream.Write(bytes, 0, bytes.Length);
return response; return response;

View File

@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName> <AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace> <RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.2.5</Version> <Version>1.2.6</Version>
<PackageReleaseNotes></PackageReleaseNotes> <PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon> <PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup> </PropertyGroup>