From 3756c4f94711a5cd5eeacecf37da3809838d0f0d Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Mon, 23 Nov 2015 13:13:33 -0500 Subject: [PATCH 1/3] Fixed BOM coming through serialization :(. fixes #340 --- src/OmniSharp/Middleware/EndpointMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OmniSharp/Middleware/EndpointMiddleware.cs b/src/OmniSharp/Middleware/EndpointMiddleware.cs index cf6e69c5d7..686e28f666 100644 --- a/src/OmniSharp/Middleware/EndpointMiddleware.cs +++ b/src/OmniSharp/Middleware/EndpointMiddleware.cs @@ -103,7 +103,7 @@ public async Task Invoke(HttpContext httpContext) private void SerializeResponseObject(HttpResponse response, object value) { - using (var writer = new StreamWriter(response.Body, System.Text.Encoding.UTF8, 1024, true)) + using (var writer = new StreamWriter(response.Body, null, 1024, true)) using (var jsonWriter = new JsonTextWriter(writer)) { jsonWriter.CloseOutput = false; From 78b09e1a2538814b69921983c3ddf7af5c18a2bf Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Mon, 23 Nov 2015 13:19:40 -0500 Subject: [PATCH 2/3] Default encoding --- src/OmniSharp/Middleware/EndpointMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OmniSharp/Middleware/EndpointMiddleware.cs b/src/OmniSharp/Middleware/EndpointMiddleware.cs index 686e28f666..f2b92ff972 100644 --- a/src/OmniSharp/Middleware/EndpointMiddleware.cs +++ b/src/OmniSharp/Middleware/EndpointMiddleware.cs @@ -103,7 +103,7 @@ public async Task Invoke(HttpContext httpContext) private void SerializeResponseObject(HttpResponse response, object value) { - using (var writer = new StreamWriter(response.Body, null, 1024, true)) + using (var writer = new StreamWriter(response.Body, System.Text.Encoding.Default, 1024, true)) using (var jsonWriter = new JsonTextWriter(writer)) { jsonWriter.CloseOutput = false; From a453366bbc0652b75199f82b1765000b29e30a84 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Mon, 23 Nov 2015 15:24:16 -0500 Subject: [PATCH 3/3] Default encoding for coreclr, default for desktop --- src/OmniSharp/Middleware/EndpointMiddleware.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/OmniSharp/Middleware/EndpointMiddleware.cs b/src/OmniSharp/Middleware/EndpointMiddleware.cs index f2b92ff972..d55fb25d2a 100644 --- a/src/OmniSharp/Middleware/EndpointMiddleware.cs +++ b/src/OmniSharp/Middleware/EndpointMiddleware.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; @@ -100,10 +101,17 @@ public async Task Invoke(HttpContext httpContext) await _next(httpContext); } + +#if DNXCORE50 + private static readonly Encoding _encoding = System.Text.Encoding.GetEncoding(1252); +#else + private static readonly Encoding _encoding = System.Text.Encoding.Default; +#endif + private void SerializeResponseObject(HttpResponse response, object value) { - using (var writer = new StreamWriter(response.Body, System.Text.Encoding.Default, 1024, true)) + using (var writer = new StreamWriter(response.Body, _encoding, 1024, true)) using (var jsonWriter = new JsonTextWriter(writer)) { jsonWriter.CloseOutput = false;