delphi vs c# post returns different strings - utf problem? -


I am posting two forms - one in C # and one in Delphi but the result string looks different:

c # returns: ¤ @@ @@@ 1 @@sśmË ± Â0Đ ...
Delphi returns: # $ 1 e '@@ 1 @ @@@ 1 @@@@ 1 @ 'x' # $ 009 C ...

And the two things are compressed, I'm getting the error while trying to decompress the streams ... C # is 'right' - that is to say the conclusion. I'm not an expert at Delphi - I need to change some code from Delphi to C #.

C # code:

  string gateata (hashtable a parm, string server URL) {string result = ""; WebRequest request = HttpWebRequest.Create (ServerURL); request. Method = "post"; Request.ContentType = "app / x-www-form-urxcode; charset = uTF-8"; UTF 8 Encoding Encounters 8 = New System Text.UTF8 encoding (wrong); Streamer Writer Writer = New Streamer (Request.GetRquestestStream (), Encounter 8); Leading (dictionary entry element in APARAM) {author. Type (element.key + "=" + element.Value + "& amp;";); } Author. Stop it (); Writer.Dispose (); WebResponse Response = Request.GetResponse (); StreamerMinder Reader = New Streamminder (North Gate ResponseScream), System.Text.Encoding.Default); Result = Reader Readout (); Reader.Close (); Response.Close (); Reader.Dispose (); Return result; } Delphi code:   
  GetData (aParam: TStringList; ServerURL: string): string; Var Rick: TIDHTP; Res: string; Start req: = TIdHTTP.Create (); Request with request. Contact Type: 'Application / x-www-form-urlencoded; Charset = UTF-8 '; request. Method: = 'Post'; request. Customers: = 'UTF-8'; request. Accept pricingSet: = 'utf-8'; Res: = Post (server URL, aParam); End; Result: = Reservations; Req.Free; End;  

- Edit - I am using Delphi 2010

It turns out that changing the post method to the one that uses the streams, resolves this issue. As I have found on some sites: "TIdHTTP.Post () does not yet support Unicode posting from a TStringList. You have to save Unicode in a separate TStream first and then post it."

Function GetData (aParam: TStringList; aurl: string): string; Var Rick: TIDHTP; I: integer; Wars: string; Reichstream; Feedback: Stream: Teestring Stream; Start Wars: = ''; I: = 0 to Peram. Calculation - Start 1Wars: = WARS + EPARAM Name [i] + '=' + Epam. Valueform [I] + '& amp;'; End; ReqStream: = TStringStream.Create (Wars); Feedback: = TStringStream.Create; Req: = TIdHTTP.Create (); Request with request. URL: = aurl; Request.ContentType: '' Application / x-www-form-urlencoded '; request. Method: = 'Post'; request. Customers: = 'UTF-8'; request. Accept the site: = 'UTF-8'; End; Req.post (aurl, reqstream, responsestream); Results: = responsestream.DataString; ReqStream.Free; ResponseStream.Free; Req.Free; End;

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -