From 68afd6fcc68bce8c4b67e6245efe9dbe61a5f96d Mon Sep 17 00:00:00 2001 From: Zack Date: Sun, 22 Feb 2015 16:07:59 -0500 Subject: [PATCH] Make sure to write the correct number of bytes, as UTF8 can and most likely will be more than one byte per char. Fixes #863 --- TShockAPI/Rest/Rest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 4fbf94e4..17c032cd 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -157,7 +157,8 @@ namespace Rests e.Response.Connection.Type = ConnectionType.Close; e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8"); e.Response.Add(serverHeader); - e.Response.Body.Write(Encoding.UTF8.GetBytes(str), 0, str.Length); + var bytes = Encoding.UTF8.GetBytes(str); + e.Response.Body.Write(bytes, 0, bytes.Length); e.Response.Status = HttpStatusCode.OK; }