NSString* urlEncode(NSString * url)
{
string inStr = StringFromNSString(url);
CFStringRef inStringRef = CFStringCreateWithCString(kCFAllocatorDefault, inStr.c_str(), kCFStringEncodingUTF8);
NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)inStringRef,NULL,(CFStringRef)@"!*’();:@&=+$,/?%#[]",kCFStringEncodingUTF8);
return encodedString;
}
我使用上面的方法來編碼網址...即使我的應用程序崩潰說如何編碼URL
<body>
<div id="content">
<h1>An Error Was Encountered</h1>
<p>The URI you submitted has disallowed characters.</p> </div>
</body>
</html>
terminate called after throwing an instance of 'std::invalid_argument'
what():
任何想法。什麼是錯我的代碼? JSONNode jsonObject0 = libJSON :: parse(inResponseData);這個方法在這個方法中崩潰了。
已更新:我發送消息的服務器是UNIX服務器是否導致問題?
提供您發送的實際URL會很有幫助.. – reflog 2011-01-27 10:17:15