0

I have some units as "m/s". But, in dotnet I get the value as "m%2Fs". How can I decode and encode it back? I tried using the following but didn't work.

HttpUtility.HtmlDecode("m%2Fs");
HttpUtility.HtmlEncode("m/s");
System.Convert.ToBase64String("m/s");
System.Convert.FromBase64String("m%2Fs");
tangel
  • 309
  • 1
  • 3
  • 12
  • Where in your application do you get this value? Can you [edit] your post with a [mre]? – gunr2171 Jul 14 '22 at 03:13
  • It's a third party application. When I make a call to that API, this is what I get. – tangel Jul 14 '22 at 03:15
  • Does this answer your question? [How do I decode a URL parameter using C#?](https://stackoverflow.com/questions/1405048/how-do-i-decode-a-url-parameter-using-c) – Charlieface Jul 14 '22 at 10:06

1 Answers1

3
using System.Web;
Console.WriteLine(HttpUtility.UrlDecode("m%2Fs"));
Console.WriteLine(HttpUtility.UrlEncode(@"m/s"));

result

m/s
m%2fs
AlanK
  • 1,827
  • 13
  • 16