2
votes

With Delphi 7 and Indy 9.00.10 I'm using a REST API with JSON. I create a GET request with the TidHTTP component like this.

IdHTTP1.HandleRedirects := True;
IdHTTP1.ReadTimeout     := 5000;
IdHTTP1.Request.Accept  := 'application/json';
IdHTTP1.Request.AcceptCharSet  := 'UTF-8';
IdHTTP1.Request.AcceptLanguage := 'sv';
IdHTTP1.Request.ContentType    := 'application/json';
Memo1.Text := IdHTTP1.Get('http://api.arbetsformedlingen.se/af/v0/platsannonser/7088149');

I have tried several charset but can not correct the Swedish characters like å,ä,ö in the response.

  • å becomes Ã¥
  • ä becomes ä
  • ö becomes ö

What am I doing wrong here?

1
Reply starts with <?xml version="1.0" encoding="UTF-8" standalone="yes"?>. - LU RD
Thanks for the additional info. Now when I try it, I can clearly see the ä, ö and å characters correctly in the memo, as e.g. " konsult om du söker en värld av" - Tom Brunberg
Strange, i still get this link Im jusing Delphi 7 with Indy 9.00.10 - Fusecube

1 Answers

7
votes

In Delphi 7 System unit there's an UTF8ToAnsi() function. Use like this:

  Memo1.Text := UTF8ToAnsi(IdHTTP1.Get('http://api.arbetsformedlingen.se/af/v0/platsannonser/7088149'));

The result is correct in Delphi 7.