2020-02-09 02:35:16 +00:00
|
|
|
using System.Net;
|
2017-11-05 09:42:03 +00:00
|
|
|
using System.Text;
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Helpers
|
2017-11-05 09:42:03 +00:00
|
|
|
{
|
|
|
|
public static class WebUtilityHelpers
|
|
|
|
{
|
|
|
|
public static string UrlEncode(string searchString, Encoding encoding)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(searchString))
|
|
|
|
{
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var bytes = encoding.GetBytes(searchString);
|
2017-11-05 09:42:03 +00:00
|
|
|
return encoding.GetString(WebUtility.UrlEncodeToBytes(bytes, 0, bytes.Length));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string UrlDecode(string searchString, Encoding encoding)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(searchString))
|
|
|
|
{
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
var inputBytes = encoding.GetBytes(searchString);
|
|
|
|
return encoding.GetString(WebUtility.UrlDecodeToBytes(inputBytes, 0, inputBytes.Length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|