Fus*_*ube 2 delphi rest json indy character-encoding
使用Delphi 7和Indy 9.00.10我正在使用带有JSON的REST API.我像这样用TidHTTP组件创建一个GET请求.
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');
Run Code Online (Sandbox Code Playgroud)
我尝试了几个字符集,但无法在响应中更正å,ä,ö等瑞典字符.
我在这做错了什么?
在Delphi 7中,System有一个UTF8ToAnsi()功能.使用这样:
Memo1.Text := UTF8ToAnsi(IdHTTP1.Get('http://api.arbetsformedlingen.se/af/v0/platsannonser/7088149'));
Run Code Online (Sandbox Code Playgroud)
结果在Delphi 7中是正确的.