title: Set UTF-8 Encoding on Azure Functions Http Trigger
body: <p><strong>EDIT</strong> Just in case im misdiagnosing, 
  Here is an example of what is sent: 
  T6NLmFUZdYYdvhxmq67WD/TiShKbE0rK0xdHXJGo5sVx9/CrmBTViiQxjqLEQN66HkAUB9LvXW6C55maPLMd7u2cwNc8OlNuPTvZfx63Aawso/2mvewXQauUytGZ1Q8D</p>
  
  <p>And what is received:
  T6NLmFUZdYYdvhxmq67WD%2fTiShKbE0rK0xdHXJGo5sVx9%2fCrmBTViiQxjqLEQN66HkAUB9LvXW6C55maPLMd7u2cwNc8OlNuPTvZfx63Aawso%2f2mvewXQauUytGZ1Q8D</p>
  
  <p>The '%2' instead of the backslash is the best example of what im talking about</p>
  
  <p><strong>EDIT2</strong>
  For those who come after: the upload handler raw did the trick, and fixed it. However, if you then want to be able to access the servers reply, you need to create a download handler. For text, use DownloadHandlerBuffer, e.g</p>
  
  <pre><code>www.downloadHandler = new DownloadHandlerBuffer();
  </code></pre>
  
  <p>Then once you have sent the request, use this to get a string response:</p>
  
  <pre><code>string response = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);
  </code></pre>
  
  <hr>
  
  <p>Im sending a REST call using Unity's UnityWebRequest, to the Azure functions HttpTrigger type functionality. </p>
  
  <p>Now, both of these functions do not expose bytes, they do that in the backend and hand me strings. 
  However, when my function is receiving my data, it is containing a lot of escaped characters, and I believe its not encoded properly. I am not sure HOW to encode it properly, considering I cant just convert my string to a byte[] with UTF8.GetBytes, and vis versa. </p>
  
  <p>Apologies if duplicate, I searched and couldnt find a similar enough issue. </p>
  
  <p>See unity and azure code here: <a href="https://pastebin.com/pE4dYSfF" rel="nofollow noreferrer">https://pastebin.com/pE4dYSfF</a></p>
  
  <pre><code>//UNITY SIDE
  IEnumerator Foo()
      {
          var N = JSON.Parse("{}");
          N["input1"] = input1.text;
          N["input2"] = input2.text;
          string encrypted = Encrypt(N.ToString(), GenerateEncryptionKey);
  
          print("ENSEND: \n" + encrypted);
          using (UnityWebRequest www = UnityWebRequest.Post(targetURL, encrypted))
          {
              yield return www.SendWebRequest();
  
              if (www.isHttpError || www.isNetworkError)
              {
                  Debug.LogError(www.error + "\n" + www.downloadHandler.text);
                  onFail?.Invoke();
              }
              else
              {
                  onSuccess?.Invoke();
                  print(www.responseCode + " : " + www.downloadHandler.text);
              }
  
          }
          yield break;
      }
  
  //FUNCTION SIDE 
  [FunctionName("UserAuthentication")]
          public static async Task&lt;IActionResult&gt; Run(
              [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
              ILogger log)
          {
              log.LogInformation("C# HTTP trigger function processed a request.");
  
              string name = req.Query["name"];
  
              string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
              try
              {
                  requestBody = Decrypt(requestBody, "Dracon");
              } catch (Exception e)
              {
  //Throwing exception here due to escaped characters
                  return new BadRequestObjectResult(e.Message + "\n" + requestBody + "\n" + Regex.Unescape(requestBody));
              }
  
              JSONNode N = null;
              try
              {
                  N = JSON.Parse(requestBody);
                  if (N["input1"] != "")
                  {
                      name = N["username"];
                      return (ActionResult)new OkObjectResult($"Hello, {name}");
                  } else if (name != "")
                  {
                      return (ActionResult)new OkObjectResult($"Hello, {name}");
                  } else
                  {
                      return new BadRequestObjectResult("Invalid object syntax");
                  }
              } catch (Exception e)
              {
                  return new BadRequestObjectResult("Invalid JSON provided. N = " + (N != null).ToString() + "\n" + requestBody + "\n" + e.Message);
              }
          }
  </code></pre>