简体   繁体   English

如何在 Unity 中发送编码 URL 数据?

[英]How to send Encode URL data in Unity?

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.我的问题是,当 REST API 调用被执行时,字符 %e2%80%8b 或 %E2%80%8b 在 pageTitle 变量之后被添加到 ZE6B391A8D2C4D459702A23A8B68 之后。 I was wondering how I can remove these characters from the URL when it is being sent.我想知道如何在发送时从 URL 中删除这些字符。

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 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我希望 URL 看起来像这样: https://en.wikipedia.org/api/rest_v1/page/summary/Cat?redirect=true

Unity's EscapeURL function is doing its job and replacing appropriate characters with URL encoded characters. Unity 的 EscapeURL function 正在完成它的工作,并用 URL 编码字符替换适当的字符。 The %e2%80%8b code is for zero width space characters. %e2%80%8b 代码用于零宽度空格字符。 If you are certain about the pageTitle string being a valid URL string then just remove the Escape URL function.如果您确定 pageTitle 字符串是有效的 URL 字符串,则只需删除 Escape URL function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM