0

I'm experiencing a weird issue that I'm not able to find any answers for.

We using Delhi XE1 and a TidHttp.Get(...) converts these letters:

æøå ÆØÅ äö ÄÖ

To these wrong letters: aoa AOA ao AO

Which of cause end up giving us a faulty URL. I suspect some unicode issues might be involved, but does anyone have a clue on how to solve this? The URL I'm providing in the call to TidHTTP.Get(...) is correct, but the destination server gets the wrong letters. Indy converts these letters some how.

I cannot post any coding samples.

Best regards, Brian Andersen

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Brian Andersen
  • 65
  • 1
  • 10

1 Answers1

1

The version of TIdHTTP.Get() that returns a String converts the server's raw data to Unicode using the charset specified in the server's response, or a default if there is no charset detected. The symptom you are experiencing is caused by the raw data being converted to Unicode using the wrong charset. Since you did not show the actual HTTP response data, it is difficult to tell whether the HTTP response or TIdHTTP is at fault. However, XE1 is a bit old, and there have been changes to Indy's charset handling since that time, so you should upgrade to the latest development snapshot of Indy and see if the problem still continues.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thanks for your answers. It's not the response that I am worried about. It is the request that I am sending that's wrong. When the parameter value (which is correct when debugging) to THttp.Get contains Danish or Swedish letters then they are converted into something wrong. Indy converts these letters. – Brian Andersen Oct 08 '13 at 09:14
  • Latest SVN of Indy dated October 08, 2013 did not solve the transformation of letters problem either. – Brian Andersen Oct 08 '13 at 09:27
  • CORRECTION: I wasn't using the latest version. It now correctly installed. Now the letters are wrongly translated into ?????. – Brian Andersen Oct 08 '13 at 10:14
  • 2
    That means you are still using the wrong charset for encoding the characters. Please update your question to show your actual code and the actual data you are trying to send to the server. The only way to send data with `GET` is via the URL, which is very limited in what characters it allows. Data needs to be charset-encoded (usually with UTF-8, but not always) and URL-encoded (converting non-ASCII and reserved octets into `%HH` notation). You have to do all of that manually when creating the URL, such as with `TIdURI.URLEncode()`. `TIdHTTP` will not do that for you automatically. – Remy Lebeau Oct 08 '13 at 16:30
  • Hi Remy. You are correct. Before I posted here I did try to convert into hex, but it failed. What I later discovered was that I shouldn't convert non ascii on the complete URL, but only on the URL parameter values. Which makes perfectly sense ;o) – Brian Andersen Oct 09 '13 at 05:47