c++ builder 2009 使用TIdHTTP控件的post方法提交汉字时接收端是乱码
如题使用post方法提交汉字信息时接收端接收的数据是乱码,接收端使用java写的编码是utf-8,这个问题怎么解决?
TIdHTTP *IdHTTP = new TIdHTTP(NULL);
TIdMultiPartFormDataStream *stream = new TIdMultiPartFormDataStream();
TStringStream *ss=new TStringStream();
TMemoryStream *ms = new TMemoryStream();
TStringList *sl = new TStringList();
IdHTTP->AllowCookies = true;
IdHTTP->HandleRedirects = true;
IdHTTP->ConnectTimeout = 3000;
IdHTTP->ReadTimeout = 3000;
String sURL = "http://192.168.1.109:8080/SynPro/SFBmd.do";
stream->AddFormField("PLATENO", "你好!");
stream->AddFormField("PLATECOLOR", "蓝色");
IdHTTP->Request->ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
__try{
IdHTTP->Post(sURL, stream, ss);
String sR = ss->DataString;
FormLogin->Memo1->Lines->Insert(0, sR);
delete ss;
delete stream;
delete IdHTTP;
bResult = true;
}
catch(Exception &ee)
{
FormLogin->Memo1->Lines->Insert(0, "进入异常处理!"+ee.Message);
delete ss;
delete stream;
delete IdHTTP;
}
[解决办法]
貌似汉字要url编码的,似乎有个函数HttpEncode可以编码