1

I have a c# app that sometimes has to work with strings like:

"example\x27s string"

How do I decode that? I know 27 is the ascii code for a single quote ', but UrlDecode() wont work on that string.

Should I replace the \x value with % and then use System.Web.HttpUtility.UrlDecode() or is there another way to do it?

meklarian
  • 6,595
  • 1
  • 23
  • 49
prekam
  • 23
  • 3
  • 1
    possible duplicate of [How to decode HTML encoded character embedded in a json string](http://stackoverflow.com/questions/1101532/how-to-decode-html-encoded-character-embedded-in-a-json-string) – Richard Marskell - Drackir Apr 06 '11 at 23:59

1 Answers1

1

\x27 is not an HTML encoded value. This is a string Escape character. The truth behind it though is that in the actual string is probably a physical \ character so what you're dealing with is:

"\\x27"

Or

@"\x27"

I am unsure if .NET has a way to re-evaluate a string, but the \codes for strings are handled on a compiler level if i remember correctly.

You could use regular expressions to do a replacement if you want, since you know what it represents.

Aren
  • 54,668
  • 9
  • 68
  • 101