I am using Indy 10 with Delphi 6 and until now managed to pass contents as UTF-8.
Unfortunately, params are parsed as ANSI, replacing, for example, ö with o when not the central european code page is the default.
Could I get POST request parameters at least as UTF-8 if I am not able to get WideString immediately?
procedure TTheServer._serverCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); // Indy 10 begin ARequestInfo.Params.Values['ParamName']; // Returns ANSI in Delphi 6 end;
ARequestInfo.Paramsis already parsed as UTF-8 by default. However, since theParamsis aTStringsholdingAnsiStringvalues in Delphi 6, the decoded UTF-8 will be converted to the OS default codepage when stored in theParams. If the POST data is%C3%B6then you should be gettingöin theParamson a European system, but that's not guaranteed on other systems. There is currently no option to specify a different codepage for the decodedAnsiStrings. If you need that, you can parse theARequestInfo.UnparsedParamsyourself.ARequestInfo.UnparsedParamsto bypass WideString to AnsiString conversion.TIdHTTPRequestInfo.DecodeAndSetParams()as a base. You would simply need to pass in the extraADestEncodingparameter toTIdURI.URLDecode(), which is not currently being passed in, hence why the OS default is being used.