字符串如何转换为ASCII吗?
如我现在的字符串为“defsdfsd=34343&searchdata=203434343&”,如何把它转为为ASCII码呢,先感谢
[解决办法]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String s= "defsdfsd=34343&searchdata=203434343& ";
TStringList* theList;
theList=new TStringList;
char c;
for(int i=1;i <s.Length()+1;i++)
{
c=s[i];
theList-> Add(IntToHex((int)c,1));
}
ShowMessage(theList-> CommaText);
delete theList; theList=0;
}
[解决办法]
AnsiString strText = "defsdfsd=34343&searchdata=203434343& ";
AnsiString strANSI = " ";
for (int i = 0; strText.Length(); i++)
{
char ch = strText.c_str()[i];
strANSI = strANSI + IntToHex(ch);
}