Get UTF8 Encoded HTTP Response in Delphi

var
  MS: TMemoryStream;
  SS: TStringStream ;
begin
  try
    MS := TMemoryStream.Create;
    SS := TStringStream.Create('',TEncoding.UTF8);
    IdHTTP1.Get('http://google.com',MS);
    MS.SaveToStream(SS);
    mystring := SS.DataString;
  finally
    FreeAndNil(IdHTTP1);
  end;
end;
Advertisements