How to send Encode URL data in Unity?

Viewed 61

My problem is that when the REST API call is executed, the character %e2%80%8b or %E2%80%8b is added to the URL after the pageTitle variable. I was wondering how I can remove these characters from the URL when it is being sent.

Here is my code:

public static string pageTitle = "Cat";

My code inside the method:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://en.wikipedia.org/api/rest_v1/page/summary/" + UnityWebRequest.EscapeURL(pageTitle) + "?redirect=true");

The URL I get looks like this: https://en.wikipedia.org/api/rest_v1/page/summary/Cat%e2%80%8b?redirect=true Or https://en.wikipedia.org/api/rest_v1/page/summary/Cat%E2%80%8b?redirect=true

I want the URL to look like this: https://en.wikipedia.org/api/rest_v1/page/summary/Cat?redirect=true

1 Answers

Unity's EscapeURL function is doing its job and replacing appropriate characters with URL encoded characters. The %e2%80%8b code is for zero width space characters. If you are certain about the pageTitle string being a valid URL string then just remove the Escape URL function.

Related