1

Some of my wide strings contains characters escaped with &# For example: The wide string source looks like: '   ' The converted result must be ' ' (3 blank spaces).

Function should look like

function UriUnescape(const aSrc: WideString): WideString;
begin
  //Your code goes here
end;

Note: 1) I am using Delphi 7.

2) This wide string is part of a SOAP response not HTML.

3) In general this method should accept alphanumeric characters as part of the wide string: example input :='be @' result := 'be @'

mas_oz2k1
  • 2,851
  • 3
  • 34
  • 41

1 Answers1

9

Your C# link is about URL unescaping but your source string looks more like HTML encoded. In that case, see HtmlDecode function in HttpApp unit.

If you want URL decoding you could try HttpDecode or Indy's TIdURL.URLDecode.

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
  • @arioch which is exactly what you would want to happen – David Heffernan Nov 22 '12 at 07:59
  • @David yes, probably. That was the point. It is easy to make ad hoc parser for [numeric SGML entities](http://en.wikipedia.org/wiki/Numeric_character_reference) alone, maybe even easier than searching through libraries (at least definitely less dependencies), but then one day it might unexpectedly break suddenly met named ones. – Arioch 'The Nov 22 '12 at 08:22
  • These functions do not work, I still do not have the desired result (3 blanks) – mas_oz2k1 Nov 22 '12 at 20:15
  • @mas_oz2k1 `HtmlDecode(' ')` returns `' '` (3 blanks). – Ondrej Kelle Nov 22 '12 at 22:11
  • HTMLDecode works OK, I was testing HTTPDecode and UrlDecode that do not work for this scenario. – mas_oz2k1 Nov 22 '12 at 23:30