0

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; 
3
  • Are you using an up-to-date version of Indy? The ARequestInfo.Params is already parsed as UTF-8 by default. However, since the Params is a TStrings holding AnsiString values in Delphi 6, the decoded UTF-8 will be converted to the OS default codepage when stored in the Params. If the POST data is %C3%B6 then you should be getting ö in the Params on a European system, but that's not guaranteed on other systems. There is currently no option to specify a different codepage for the decoded AnsiStrings. If you need that, you can parse the ARequestInfo.UnparsedParams yourself. Commented Aug 21, 2023 at 19:58
  • @Remy Lebeau: Thank you for the support. I will try to parse ARequestInfo.UnparsedParams to bypass WideString to AnsiString conversion. Commented Aug 22, 2023 at 17:46
  • 1
    Look at the source code for TIdHTTPRequestInfo.DecodeAndSetParams() as a base. You would simply need to pass in the extra ADestEncoding parameter to TIdURI.URLDecode(), which is not currently being passed in, hence why the OS default is being used. Commented Aug 22, 2023 at 18:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.