i writed few day ago the question about "Delphi & Indy & utf8" who you are help me to resolved the charset codified in utf8, but sometime the same routine is used to access other www with other charset.
the routine is this (in delphi xe6):
var
Web: TIdHTTP;
ASito : AnsiString;
TStr : TStringStream;
hIOHand: TIdSSLIOHandlerSocketOpenSSL;
begin
try
Web := TIdHTTP.Create(nil);
TStr := TStringStream.Create('',TEncoding.UTF8);
hIOHand := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
hIOHand.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2,sslvSSLv23];
Web.IOHandler := hIOHand;
Web.Request.UserAgent := INET_USERAGENT; //Custom user agent string
Web.RedirectMaximum := INET_REDIRECT_MAX; //Maximum redirects
Web.HandleRedirects := INET_REDIRECT_MAX <> 0; //Handle redirects
Web.ReadTimeOut := INET_TIMEOUT_SECS * 1000; //Read timeout msec
Web.ConnectTimeout := INET_TIMEOUT_SECS div 2 * 1000;
try
Web.Get(FUrl,TStr);
Sito := TStr.DataString;
except
on e : exception do
Sito := 'ERR: ' +FUrl+#32+e.Message;
end
finally
EndTime := Now;
TStr.Free;
Web.Free;
hIOHand.Free;
end;
What is the method to define the charset code at one any www page? Some page who i access are in json (and i must use utf8 in this case). I tried more options… but i can't able to fine the correct solution.
thakyou all for the help!