In what way exactly does it not work? Please be more specific.
When I request that URL, the response's 'Content-Type' header reports 'charset=GBK'. TIdHTTP will thus attempt to decode the response body data from GBK to UTF-16, and then convert that result to UTF-8. On Linux, those conversions are done using the libiconv library. On Windows, those conversions are done using the Win32 API MultiByteToWideChar() and WideCharToMultiByte() functions using codepages 936 and 65001, respectively.
I would suggest downloading the server's data as raw bytes instead of as a string, and then make sure the bytes really are GBK encoded, and then manually check whether it is the GBK->UTF16 or UTF16->UTF8 conversion that is failing, eg:
var
Strm: TMemoryStream;
Bytes: TIdBytes;
sTemp: TIdUnicodeString;
sResult: string;
begin
Strm := TMemoryStream.Create;
try
IdHTTP1.Get("http://hq.sinajs.cn/list=sz000933,sh600795", Strm);
Strm.Position := 0;
ReadTIdBytesFromStream(Strm, Bytes, -1);
finally
Strm.Free;
end;
// verify Bytes are GBK encoded...
sTemp := IndyTextEncoding('GBK').GetString(Bytes);
// verify sTemp is correct...
Bytes := IndyTextEncoding('utf-8').GetBytes(sTemp);
// verify Bytes is correct...
SetString(sResult, PAnsiChar(Bytes), Length(Bytes));
end;
Also, just curious, why are you using IndyTextEncoding('utf-8') instead of using IndyTextEncoding_UTF8()? It doesn't really matter in this case, as the former will just call the latter for you.