XE7下,IdHTTPServer的CommandGet取POST中文乱码问题,但是同样D7不会,怎么解决?
代码完全一样,XE7就乱码了
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
Request: string;
begin
ARequestInfo.ContentType :='text/html;Charset=UTF-8';
Request :=UTF8Decode(ARequestInfo.Params.text);
Memo1.Lines.Add(FormatDateTime('YYYY-MM-DD HH:NN:SS',NOW) +'rev:'+Request);
AResponseInfo.ContentType :='text/html;Charset=UTF-8';
AResponseInfo.ContentText:=UTF8Encode(Request);
end;
代码完全一样,XE7就乱码了
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
Request: string;
begin
ARequestInfo.ContentType :='text/html;Charset=UTF-8';
Request :=UTF8Decode(ARequestInfo.Params.text);
Memo1.Lines.Add(FormatDateTime('YYYY-MM-DD HH:NN:SS',NOW) +'rev:'+Request);
AResponseInfo.ContentType :='text/html;Charset=UTF-8';
AResponseInfo.ContentText:=UTF8Encode(Request);
end;
Request := ARequestInfo.UnparsedParams;
Request := HttpApp.HTTPDecode(Request);
这样就可以了