1

I have a text such as "abc\u001357". It's a parameter in json object which I send from client to server via http. How can I convert that text to a string like "abc%1357". I tried with Regex to replace characters. But it doesn't work

Thanks for advance

AcidBurn
  • 73
  • 2
  • 15
  • try unicodeencoding https://msdn.microsoft.com/en-us/library/system.text.unicodeencoding(v=vs.110).aspx – Kalyan Sep 09 '17 at 04:47
  • https://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode#7885499 – alsafoo Sep 09 '17 at 04:51
  • Http has special characters. See wiki : https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references. To encode/decode in c# use : System.Net.WebUtility.HtmlDecode() or System.Net.WebUtility.HtmlEncode() – jdweng Sep 09 '17 at 04:58

1 Answers1

0

Try this code

var str = Uri.EscapeUriString("abc\u001357");
Znaneswar
  • 3,329
  • 2
  • 16
  • 24