Home > Back-end >  Piss me off, XE8 IDHttp Post back is always garbled
Piss me off, XE8 IDHttp Post back is always garbled

Time:09-18

Trapped for a week, tried to search online, all tried, originally used on D7, everything is normal, not on the XE8 anyway, return to the Chinese are "???????????????????? 0???????? 1????? 2?????? "So, who can help me!!!!!!!!

CodePudding user response:

How do you write under xe8 code

CodePudding user response:

Try the UT8Decode decoding?

CodePudding user response:

Used UTF8Decode, UTF8ToAnsi and

CodePudding user response:

T:
=TStringStream. Create (' ', tencoding UTF8); 
Idhttp1. Post (SvrUrl + postUrl, ts, t);
Result:=Utf8ToAnsi (t.D ataString); Or the Result:=Utf8Decode (t.D ataString);
Or
T:=TStringStream. Create (' ', tencoding. ANSI);
Idhttp1. Post (SvrUrl + postUrl, ts, t);
Result:=t.D ataString;

Not all,
To determine the site returns the UTF8, also use IDHttp under Delphi7 returns is normal

CodePudding user response:

Can you send up the url

CodePudding user response:

http://app.25hours.cc:6077/webservice/25hours.asmx/StruUp
Post:data=https://bbs.csdn.net/topics/{" ShopID ": 1," SyncVer ": 200}
My own server

CodePudding user response:

 procedure TForm1. Button1Click (Sender: TObject); 
Var
T: TStringStream;
Ts: TStringList;
SvrUrl postUrl: string;

The begin
SvrUrl:='http://app.25hours.cc:6077/webservice/25hours.asmx/StruUp';
PostUrl:=';
Ts:=TStringList. Create;
Ts. Text:='data=https://bbs.csdn.net/topics/{" ShopID ": 1," SyncVer ": 200}';

T:=TStringStream. Create (' ', tencoding UTF8);
IdHTTP1. Post (SvrUrl + postUrl, ts, T);
Memo1. Text:=T.D ataString;
end;


After the test, there is no garbled
{" error ": 0," MSG ":" table structure upgrade success!" , 247, "Count" : "Stru" : [{" ID ": 201," SqlStr ":" the CASE "}, {" ID ", 202, "...

CodePudding user response:

Reference:
IdURI;

Use:
TidURI. URLDecode (MyHttp. Get (TidURI URLEncode (uploadstr)));

CodePudding user response:

According to the 7 floor, there is no garbled words, the problem may be on your operating system, please change to computer, or try to reinstall system,

CodePudding user response:

Don't outside the failures of Chinese character input method, also can appear similar problems,

CodePudding user response:

According to the 7th floor that could it be that the building Lord XE8 project Settings have what you need to change? I also encountered the same problem of the great god, please answer the other the building Lord what progress?

CodePudding user response:

Find a solution, use tstringstream as the return type, part of the code reference:
 responsejson: tstringstream; 
Responsejson:=tstringstream. Create (', 65001);
HTTP post (URL, StringList, responsejson);
Memo1. Lines. The Add (responsejson DataString);

The inside of the responsejson. DataString Chinese not garbled!
Reference solution from http://blog.sina.com.cn/s/blog_549f50ec01019cgc.html,

CodePudding user response:

The
reference 7 floor ksrsoft response:
 procedure TForm1. Button1Click (Sender: TObject); 
Var
T: TStringStream;
Ts: TStringList;
SvrUrl postUrl: string;

The begin
SvrUrl:='http://app.25hours.cc:6077/webservice/25hours.asmx/StruUp';
PostUrl:=';
Ts:=TStringList. Create;
Ts. Text:='data=https://bbs.csdn.net/topics/{" ShopID ": 1," SyncVer ": 200}';

T:=TStringStream. Create (' ', tencoding UTF8);
IdHTTP1. Post (SvrUrl + postUrl, ts, T);
Memo1. Text:=T.D ataString;
end;


After the test, there is no garbled
{" error ": 0," MSG ":" table structure upgrade success!" , 247, "Count" : "Stru" : [{" ID ": 201," SqlStr ":" the CASE "}, {" ID ", 202, "...


Close test useful!

CodePudding user response:

So should be back to the data type of the flow,

CodePudding user response:

Before also found a lot of ways, Chinese use AnsiString WideString turn not,
Then test:
Delphi7 Chinese use UTF8Encode (inValue);
Java with URLDecoder. Decode (inValue, "utf-8");
can

CodePudding user response:

  • Related