views:

453

answers:

2

I read data from a mysql database that has is filled by php scripts. All special characters are converted to named or numbered html entities (for example & a m p ; & # 2 8 6 ;). I know of no way to convert these characters back to the original ones in Delphi as unicode strings. Did anyone ever find or even create such a function? This would be very helpful to me. Thanks! Marc

+6  A: 

In Delphi 2007 there is a unit called HTTPApp.pas (in [Delphi Folder]\Source\Win32\Internet) that has the functions HTMLEncode and HTMLDecode. They might be worth a look.

Pauk
Right, this really looks interesting.I will test this unit later on, but as far as i can see this seems to solve the question.Thanks!
It's in D2006 as well
Gerry
A: 

Anyone still out there using Delphi? :)

We are having problems with unicode characters too. It seems that HTTPApp.DecodeHTML only supports Ansi (aargh).

When we post this text

hyphen ( -, ‐ )

in a textarea to the Delphi web server app and then, in the debugger, inspect Request.ContentFields, it looks like this:

hyphen ( -, & # 8 2 0 8 ; )

Note the HTML encoded value: & # 8 2 0 8 ;

(ignore the spaces; this site has some encoding problems itself too :-)

For some reason (probably that it does not fit in AnsiString?) it is not decoded?

Does anyone have any experience with this? How do we solve it?

It really is a problem, because ContentFields is so low level, we use it everywhere in our app.