Jump to content

Recommended Posts

Posted

Dear:

I user xe10.3.3 to develop a http pos interface,

In my VCL APPLICATION,my project works well,the remote host can receive the right message without encoding problem,

first I call AnsiToUtf8,then I call IdHTTP1->post the data,and IdHTTP1 have be set forceParamsEncode。

But when I use the same code in UNIGUI,the remote host receive the message,but the message is confusion codes.

why?

How to send a message like this with c++builder?

String  myStr:='你好hello';

HTTPEncode(AnsiToUtf8(myStr));

 

String __fastcall TFormMain::sendHangxin(String destUrl,String sendNo,String userNo,String corpNo,String sendInfo)
{
/*
调用行信推送消息
*/
String dataStr="sendNo="+sendNo+"&userNo="+userNo+"&corpNo="+ corpNo+"&sendInfo="+sendInfo;;
TStringStream *postData=new TStringStream(dataStr,TEncoding::UTF8,true);
TStringStream *respData=new TStringStream();

IdHTTP1->ReadTimeout=5000;//5秒
IdHTTP1->Request->ContentType="application/x-www-form-urlencoded";
IdHTTP1->Request->Accept="application/json";

IdHTTP1->Post(destUrl,postData,respData);

Memo1->Lines->Add(dataStr);

Memo2->Lines->Add(Utf8ToAnsi(respData->DataString));

delete postData;
delete respData;
}
 

 

Posted
5 hours ago, 55143681 said:

Dear:

I user xe10.3.3 to develop a http pos interface,

In my VCL APPLICATION,my project works well,the remote host can receive the right message without encoding problem,

first I call AnsiToUtf8,then I call IdHTTP1->post the data,and IdHTTP1 have be set forceParamsEncode。

But when I use the same code in UNIGUI,the remote host receive the message,but the message is confusion codes.

why?

How to send a message like this with c++builder?

String  myStr:='你好hello';

HTTPEncode(AnsiToUtf8(myStr));

 

String __fastcall TFormMain::sendHangxin(String destUrl,String sendNo,String userNo,String corpNo,String sendInfo)
{
/*
调用行信推送消息
*/
String dataStr="sendNo="+sendNo+"&userNo="+userNo+"&corpNo="+ corpNo+"&sendInfo="+sendInfo;;
TStringStream *postData=new TStringStream(dataStr,TEncoding::UTF8,true);
TStringStream *respData=new TStringStream();

IdHTTP1->ReadTimeout=5000;//5秒
IdHTTP1->Request->ContentType="application/x-www-form-urlencoded";
IdHTTP1->Request->Accept="application/json";

IdHTTP1->Post(destUrl,postData,respData);

Memo1->Lines->Add(dataStr);

Memo2->Lines->Add(Utf8ToAnsi(respData->DataString));

delete postData;
delete respData;
}
 

 

 

#include "System.NetEncoding.hpp"

 

String myStr="adffad":

 

TNetEncoding::URL->Encode(myStr);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...